コード例 #1
0
ファイル: test_constraints.py プロジェクト: varokas/dagster-1
def test_non_nullable_column_constraint():
    test_dataframe = DataFrame({'foo': ['baz']})
    assert NonNullableColumnConstraint().validate(test_dataframe, 'foo') is None

    bad_test_dataframe = DataFrame({'foo': ['baz', None]})
    with pytest.raises(ConstraintViolationException):
        NonNullableColumnConstraint().validate(bad_test_dataframe, 'foo')
コード例 #2
0
ファイル: test_constraints.py プロジェクト: zuik/dagster
def test_non_nullable_column_constraint():
    test_dataframe = DataFrame({"foo": ["baz"]})
    assert NonNullableColumnConstraint().validate(test_dataframe,
                                                  "foo") is None

    bad_test_dataframe = DataFrame({"foo": ["baz", None]})
    with pytest.raises(ConstraintViolationException):
        NonNullableColumnConstraint().validate(bad_test_dataframe, "foo")
コード例 #3
0
ファイル: validation.py プロジェクト: zkan/dagster
def _construct_keyword_constraints(non_nullable, unique):
    non_nullable = check.bool_param(non_nullable, 'exists')
    unique = check.bool_param(unique, 'unique')
    constraints = []
    if non_nullable:
        constraints.append(NonNullableColumnConstraint())
    if unique:
        constraints.append(UniqueColumnConstraint())
    return constraints
コード例 #4
0
ファイル: validation.py プロジェクト: sarahmk125/dagster
def _construct_keyword_constraints(non_nullable, unique, ignore_missing_vals):
    non_nullable = check.bool_param(non_nullable, "exists")
    unique = check.bool_param(unique, "unique")
    ignore_missing_vals = check.bool_param(ignore_missing_vals, "ignore_missing_vals")
    if non_nullable and ignore_missing_vals:
        raise DagsterInvariantViolationError(
            "PandasColumn cannot have a non-null constraint while also ignore missing values"
        )
    constraints = []
    if non_nullable:
        constraints.append(NonNullableColumnConstraint())
    if unique:
        constraints.append(UniqueColumnConstraint(ignore_missing_vals=ignore_missing_vals))
    return constraints
コード例 #5
0
ファイル: test_data_frame.py プロジェクト: sd2k/dagster
def test_dataframe_description_generation_multi_constraints():
    TestDataFrame = create_dagster_pandas_dataframe_type(
        name="TestDataFrame",
        columns=[
            PandasColumn(
                name="foo",
                constraints=[
                    ColumnDTypeInSetConstraint({"int64"}),
                    InRangeColumnConstraint(0, 100, ignore_missing_vals=False),
                    NonNullableColumnConstraint(),
                ],
            ),
        ],
    )
    assert (
        TestDataFrame.description ==
        "\n### Columns\n**foo**: `int64`\n+ 0 < values < 100\n+ No Null values allowed.\n\n"
    )
コード例 #6
0
def test_dataframe_description_generation_multi_constraints():
    TestDataFrame = create_dagster_pandas_dataframe_type(
        name='TestDataFrame',
        columns=[
            PandasColumn(
                name='foo',
                constraints=[
                    ColumnTypeConstraint('int64'),
                    InRangeColumnConstraint(0, 100),
                    NonNullableColumnConstraint(),
                ],
            ),
        ],
    )
    assert (
        TestDataFrame.description ==
        "\n### Columns\n**foo**: `int64`\n+ 0 < values < 100\n+ No Null values allowed.\n\n"
    )