Skip to content

Filters in extended sources impact the source being extended #607

@adamribaudo-ff

Description

@adamribaudo-ff

What happens?

In specific instances, the filters from an extended source can impact queries on the parent source. See the example below: source 3's filter col_1 = 1 is included in publisher's SQL compilation when querying source 2

To Reproduce

source: source_1 is bigquery.sql("Select 1 as col_1, 2 as col_2 union all select 2 as col_1, 3 as col_2")

source: source_2 is source_1
extend {
//The inclusion of this where clause line impacts whether source_3's filter impacts queries run on source_2
    where: 1=1
}

source: source_3 is source_2
extend {
    dimension:
        test_dim is 1
    where:
        col_1 = 1
}

Malloy query to run:

run: source_2 -> {
  group_by:
    col_1
    col_2
}

Compiled SQL in VS Code:

SELECT 
   base.`col_1` as `col_1`,
   base.`col_2` as `col_2`
FROM (Select 1 as col_1, 2 as col_2 union all select 2 as col_1, 3 as col_2) as base
WHERE 1=1
GROUP BY 1,2
ORDER BY 1 asc NULLS LAST

Compiled SQL in publisher:

SELECT 
   base.`col_1` as `col_1`,
   base.`col_2` as `col_2`
FROM (Select 1 as col_1, 2 as col_2 union all select 2 as col_1, 3 as col_2) as base
WHERE (1=1)
AND (base.`col_1`=1)
GROUP BY 1,2
ORDER BY 1 asc NULLS LAST

OS:

Windows

Malloy Client:

Issue in publisher server@0.0.160

Malloy Client Version:

latest vscode

Database Connection:

BigQuery

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions