我正在尝试使用 SQLAlchemy 和 Great Expectations 来测试存储在 Snowflake DB 中的数据集的数据质量。数据集被调用candidates
,感兴趣的列被调用first_name
。
但是,当我跑步时
sql_dataset = great_expectations.dataset.SqlAlchemyDataset(table_name="candidates", engine=engine, schema=creds["schema"])
sql_dataset.expect_column_values_to_be_in_set("first_name", ['Gather', 'Male'])
我正进入(状态:
ProgrammingError: (snowflake.connector.errors.ProgrammingError) 002003 (42S02): SQL compilation error:
Object 'KEBOOLA_274.WORKSPACE_48777448.CANDIDATES' does not exist or not authorized.
[SQL: SELECT count(*) AS element_count, sum(CASE WHEN (first_name IS NULL) THEN %(param_1)s ELSE %(param_2)s END) AS null_count, sum(CASE WHEN (first_name NOT IN (%(first_name_1)s, %(first_name_2)s) AND first_name IS NOT NULL) THEN %(param_3)s ELSE %(param_4)s END) AS unexpected_count
FROM "WORKSPACE_48777448".candidates]
[parameters: {'param_1': 1, 'param_2': 0, 'first_name_1': 'Gather', 'first_name_2': 'Male', 'param_3': 1, 'param_4': 0}]
(Background on this error at: http://sqlalche.me/e/13/f405)
问题是表名没有用双引号括起来,因此 Snowflake 正在寻找CANDIDATES
而不是candidates
. 如果找到表,列名也会出现同样的问题。
我测试过
sql_dataset = great_expectations.dataset.SqlAlchemyDataset(table_name="\"candidates\"",
engine=engine,
schema=creds["schema"])
bu Snowflake 正在寻找一张名为KEBOOLA_274.WORKSPACE_48777448.""candidates""
.
我知道 SQLAlchemy 默认情况下认为小写对象名称不区分大小写,因此它不包含名称。请问有什么办法吗?