Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@
"replace /*+ AWAIT */ google.compute.firewalls set data__disabled = 'true' where project = 'mutable-project' and firewall = 'replacable-firewall' returning *;",
"select split_part(rings.name, '/', -1) from google.cloudkms.key_rings rings inner join google.cloudkms.crypto_keys keys on keys.keyRingsId = split_part(rings.name, '/', -1) and keys.projectsId = 'testing-project' where rings.projectsId = 'testing-project' and rings.locationsId = 'global' and keys.locationsId = 'global';",
"select * from local_openssl.keys.x509 where cert_file = '${workspaceFolder}/test/assets/input/manual_cert.pem';",
"select t1.id as t1_id, t2.id as t2_id from (select 'my-id' as id) t1 left outer join (select a.vpcId id from aws.ec2_native.vpcs a where region = 'ap-southeast-2') t2 on t1.id = t2.id;",
],
"default": "show providers;"
},
Expand All @@ -214,7 +215,7 @@
"{ \"url\": \"file://${workspaceFolder}/test/registry-mocked\", \"localDocRoot\": \"${workspaceFolder}/test/registry-mocked\", \"verifyConfig\": { \"nopVerify\": true } }",
"{ \"url\": \"file://${workspaceFolder}/test/registry-mocked-native\", \"localDocRoot\": \"${workspaceFolder}/test/registry-mocked-native\", \"verifyConfig\": { \"nopVerify\": true } }",
"{ \"url\": \"file://${workspaceFolder}/test/registry-advanced\", \"localDocRoot\": \"${workspaceFolder}/test/registry-advanced\", \"verifyConfig\": { \"nopVerify\": true } }",
"{ \"url\": \"file://${workspaceFolder}/build/.stackql\", \"localDocRoot\": \"${workspaceFolder}/build/.stackql\", \"verifyConfig\": { \"nopVerify\": true } }",
"{ \"url\": \"file://${workspaceFolder}/.stackql\", \"localDocRoot\": \"${workspaceFolder}/.stackql\", \"verifyConfig\": { \"nopVerify\": true } }",
"{ \"url\": \"file://${workspaceFolder}/docs/examples/empty-registry\", \"localDocRoot\": \"${workspaceFolder}/docs/examples/empty-registry\" }",
"{ \"url\": \"https://cdn.statically.io/gh/stackql/stackql-provider-registry/main/providers\", \"localDocRoot\": \"${workspaceFolder}/test/registry\" }",
"{ \"url\": \"https://cdn.statically.io/gh/stackql/stackql-provider-registry/dev/providers\" }",
Expand Down
4 changes: 0 additions & 4 deletions internal/stackql/astanalysis/earlyanalysis/ast_expand.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,6 @@ func (v *indirectExpandAstVisitor) processIndirect(node sqlparser.SQLNode, indir
if createBuilderExists {
v.createBuilder = append(v.createBuilder, createBuilder...)
}
// createBuilder, createBuilderExists := childAnalyzer.GetIndirectCreateTail()
// if createBuilderExists {
// v.createBuilder = createBuilder
// }
return nil
}

Expand Down
8 changes: 4 additions & 4 deletions internal/stackql/dbmsinternal/dbmsinternal.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ func (pgr *standardDBMSInternalRouter) analyzeTableExpr(node sqlparser.TableExpr
}
case *sqlparser.JoinTableExpr:
lhs := pgr.analyzeTableExpr(node.LeftExpr)
if lhs {
return true
if !lhs {
return false
}
rhs := pgr.analyzeTableExpr(node.RightExpr)
if rhs {
Expand All @@ -213,8 +213,8 @@ func (pgr *standardDBMSInternalRouter) analyzeTableExprAllRDBMS(node sqlparser.T
}
case *sqlparser.JoinTableExpr:
lhs := pgr.analyzeTableExprAllRDBMS(node.LeftExpr)
if lhs {
return true
if !lhs {
return false
}
rhs := pgr.analyzeTableExprAllRDBMS(node.RightExpr)
if rhs {
Expand Down
3 changes: 3 additions & 0 deletions internal/stackql/sql_system/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -1052,6 +1052,9 @@ func (eng *postgresSystem) render(alias string,
controls = append(controls, fmt.Sprintf(`%s = $%d AND %s = $%d AND %s = $%d AND %s = $%d`, gIDcn, j+1, sIDcn, j+2, tIDcn, j+3, iIDcn, j+4)) //nolint:mnd // the magic numbers are offsets
j += constants.ControlColumnCount
}
if len(controls) == 0 {
return "1 = 1"
}
return fmt.Sprintf(`( %s )`, strings.Join(controls, " OR "))
}

Expand Down
3 changes: 3 additions & 0 deletions internal/stackql/sql_system/sqlite.go
Original file line number Diff line number Diff line change
Expand Up @@ -1178,6 +1178,9 @@ func (eng *sqLiteSystem) render(alias string, aliasToCountersMap map[string][]in
iIDcn := fmt.Sprintf(`"%s"`, insIDColName)
controls = append(controls, fmt.Sprintf(`( %s = ? AND %s = ? AND %s = ? AND %s = ? )`, gIDcn, sIDcn, tIDcn, iIDcn))
}
if len(controls) == 0 {
return "1 = 1"
}
return fmt.Sprintf(`( %s )`, strings.Join(controls, " OR "))
}

Expand Down
58 changes: 58 additions & 0 deletions test/robot/functional/stackql_mocked_from_cmd_line.robot
Original file line number Diff line number Diff line change
Expand Up @@ -9278,3 +9278,61 @@ Materialized View of Filtered Multi Level Table Valued Function In Subquery Retu
... ${outputStr}
... stdout=${CURDIR}/tmp/Materialized-View-of-Filtered-Multi-Level-Table-Valued-Function-In-Subquery-Returns-Expected-Results.tmp
... stderr=${CURDIR}/tmp/Materialized-View-of-Filtered-Multi-Level-Table-Valued-Function-In-Subquery-Returns-Expected-Results-stderr.tmp

Left Outer Join Negative LHS Inline
${inputStr} = Catenate
... select lhs.id, lhs.secondary_field, rhs.volume_id
... from
... (select 'my-id' as id, 'some other field' as secondary_field) lhs
... left outer join
... (select volume_id from aws.ec2.volumes_presented where region = 'ap-southeast-2') rhs
... on lhs.id = rhs.volume_id
... where volume_id is null
... ;
${outputStr} = Catenate SEPARATOR=\n
... |-------|------------------|-----------|
... |${SPACE}${SPACE}id${SPACE}${SPACE}${SPACE}|${SPACE}secondary_field${SPACE}${SPACE}|${SPACE}volume_id${SPACE}|
... |-------|------------------|-----------|
... |${SPACE}my-id${SPACE}|${SPACE}some${SPACE}other${SPACE}field${SPACE}|${SPACE}null${SPACE}${SPACE}${SPACE}${SPACE}${SPACE}${SPACE}|
... |-------|------------------|-----------|
Should Stackql Exec Inline Equal
... ${STACKQL_EXE}
... ${OKTA_SECRET_STR}
... ${GITHUB_SECRET_STR}
... ${K8S_SECRET_STR}
... ${REGISTRY_NO_VERIFY_CFG_STR}
... ${AUTH_CFG_STR}
... ${SQL_BACKEND_CFG_STR_CANONICAL}
... ${inputStr}
... ${outputStr}
... stdout=${CURDIR}/tmp/Left-Outer-Join-Negative-LHS-Inline.tmp
... stderr=${CURDIR}/tmp/Left-Outer-Join-Negative-LHS-Inline-stderr.tmp

Left Outer Join Positive LHS Inline
${inputStr} = Catenate
... select lhs.id, lhs.secondary_field, rhs.volume_id
... from
... (select 'vol-00200000000000000' as id, 'some other field' as secondary_field) lhs
... left outer join
... (select volume_id from aws.ec2.volumes_presented where region = 'ap-southeast-2') rhs
... on lhs.id = rhs.volume_id
... where volume_id is not null
... ;
${outputStr} = Catenate SEPARATOR=\n
... |-----------------------|------------------|-----------------------|
... |${SPACE}${SPACE}${SPACE}${SPACE}${SPACE}${SPACE}${SPACE}${SPACE}${SPACE}${SPACE}id${SPACE}${SPACE}${SPACE}${SPACE}${SPACE}${SPACE}${SPACE}${SPACE}${SPACE}${SPACE}${SPACE}|${SPACE}secondary_field${SPACE}${SPACE}|${SPACE}${SPACE}${SPACE}${SPACE}${SPACE}${SPACE}${SPACE}volume_id${SPACE}${SPACE}${SPACE}${SPACE}${SPACE}${SPACE}${SPACE}|
... |-----------------------|------------------|-----------------------|
... |${SPACE}vol-00200000000000000${SPACE}|${SPACE}some${SPACE}other${SPACE}field${SPACE}|${SPACE}vol-00200000000000000${SPACE}|
... |-----------------------|------------------|-----------------------|
Should Stackql Exec Inline Equal
... ${STACKQL_EXE}
... ${OKTA_SECRET_STR}
... ${GITHUB_SECRET_STR}
... ${K8S_SECRET_STR}
... ${REGISTRY_NO_VERIFY_CFG_STR}
... ${AUTH_CFG_STR}
... ${SQL_BACKEND_CFG_STR_CANONICAL}
... ${inputStr}
... ${outputStr}
... stdout=${CURDIR}/tmp/Left-Outer-Join-Positive-LHS-Inline.tmp
... stderr=${CURDIR}/tmp/Left-Outer-Join-Positive-LHS-Inline-stderr.tmp
Loading