mirror of
https://github.com/Kaelio/ktx.git
synced 2026-06-07 07:55:13 +02:00
feat(context): add warehouse verification tools (#46)
* feat(context): add warehouse dialect dispatch * feat(context): read warehouse scan catalog * feat(context): add entity details verification tool * feat(context): add ingest SQL verification tool * feat(context): add raw warehouse discovery tool * feat(context): expose warehouse verification tools to ingest * docs(context): add ingest identifier verification protocol * test(context): guard ingest identifier verification prompts * chore(context): verify warehouse verification tools * docs: add warehouse verification tools plan and spec * fix(context): expose target warehouses to Notion ingest * fix(context): update ingest prompts for warehouse verification tools * fix(context): scope raw schema discovery to allowed connections * fix(context): verify warehouse column display targets * docs: add notion warehouse verification gap closure plan * fix(context): include raw discovery connection names * fix(context): expose warehouse targets for LookML and MetricFlow * fix(context): pass connection config to ingest query executors * fix(cli): enable read-only SQL probes for local ingest * docs: add warehouse verification final v1 closure plan * fix(context): align warehouse sql probe prompt shape * docs: add warehouse verification prompt shape closure plan * test(context): catch connectionless sql execution prompt examples * fix(context): include connection name in sl capture sql example * docs: add warehouse verification sql example closure plan * fix(context): report structured entity detail misses * docs: add warehouse verification structured target miss closure plan * fix: report untracked squash merge conflicts * feat: require ingest verification ledger * fix: stabilize ingest wiki references
This commit is contained in:
parent
bcb0d2f8f7
commit
c22248dabf
89 changed files with 7818 additions and 191 deletions
|
|
@ -687,6 +687,12 @@ class SqlGenerator:
|
|||
if isinstance(node, exp.AggFunc):
|
||||
if isinstance(node, exp.Count):
|
||||
count_arg = node.this
|
||||
if isinstance(count_arg, exp.Star):
|
||||
node.set(
|
||||
"this",
|
||||
_make_case(exp.Literal.number(1)),
|
||||
)
|
||||
return node
|
||||
if (
|
||||
isinstance(count_arg, exp.Distinct)
|
||||
and count_arg.expressions
|
||||
|
|
|
|||
|
|
@ -243,6 +243,37 @@ def test_filtered_count_distinct_keeps_distinct_inside_count():
|
|||
assert_valid_sql(result.sql)
|
||||
|
||||
|
||||
def test_filtered_count_star_uses_case_one_not_case_star():
|
||||
engine = make_engine(
|
||||
{
|
||||
"accounts": {
|
||||
"name": "accounts",
|
||||
"table": "public.accounts",
|
||||
"grain": ["id"],
|
||||
"columns": [
|
||||
{"name": "id", "type": "number"},
|
||||
{"name": "risk_level", "type": "string"},
|
||||
],
|
||||
"measures": [
|
||||
{
|
||||
"name": "high_risk_account_count",
|
||||
"expr": "count(*)",
|
||||
"filter": "risk_level = 'high'",
|
||||
}
|
||||
],
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
result = engine.query(
|
||||
{"measures": ["accounts.high_risk_account_count"], "dimensions": []}
|
||||
)
|
||||
|
||||
assert "THEN *" not in result.sql
|
||||
assert "COUNT(CASE WHEN accounts.risk_level = 'high' THEN 1 END)" in result.sql
|
||||
assert_valid_sql(result.sql)
|
||||
|
||||
|
||||
def test_predefined_measure_via_alias_uses_real_table_and_alias_qualification():
|
||||
engine = make_engine(_alias_measure_sources())
|
||||
result = engine.query(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue