0

创建批处理并使用自定义查询不会将查询保存在 json 文件中

例如:

batch_kwargs = {'data_asset_name': 'pgsql.data_asset_name',
            'query': 'select entity_id,attribute  from table_name where attribute > 50 and',
            'datasource': 'datasource',
            'schema': 'public',
            'table': 'table_name',
            }

expectation_suite_name = "test.error"

suite = context.create_expectation_suite(
    expectation_suite_name, overwrite_existing=True  # Configure these parameters for your needs)
batch = context.get_batch(batch_kwargs, suite)

batch.expect_column_values_to_not_be_null('attribute', result_format={'result_format': 'COMPLETE','include_unexpected_rows': True})                                                                           
batch.save_expectation_suite(discard_failed_expectations=False)

只会产生一个包含期望值的json,而不是batch_kwargs。

是否有配置来保存查询本身?

4

1 回答 1

0

实现此目的的一种方法是在终端中运行“great_expectations init”,选择适合您的情况并在提示此问题时:

'您选择的数据源是 SQL 数据库。你想如何指定数据?

选择 2.输入自定义 SQL 查询

然后查询将被保存到 .json

于 2022-03-01T12:11:52.663 回答