Comments (3)
This is yet another moment when I feel amazed that it's allowed to write SQL like this.
To summarize, c2, c3 and c4 can come from src_tbl1 and src_tbl2
select
c1,
(select c2 || c3 || c4 from src_tbl1) as c2
------------^^^
from
src_tbl2
;
Again, tried a few open source SQL database:
dialect | version | src_tbl1 returns multiple rows | src_tbl1 returns 1 row |
---|---|---|---|
mysql | 8.2.0 | ERROR 1242 (21000): Subquery returns more than 1 row | yes |
postgres | 16.1 | ERROR: more than one row returned by a subquery used as an expression | yes |
hive | 3.1.3 | CalciteSubquerySemanticException [Error 10249]: Unsupported SubQuery Expression Currently SubQuery expressions are only allowed as Where and Having Clause predicates (state=42000,code=10249) | same error |
sparksql | 3.5.0 | [UNSUPPORTED_SUBQUERY_EXPRESSION_CATEGORY.MUST_AGGREGATE_CORRELATED_SCALAR_SUBQUERY] Unsupported subquery expression: Correlated scalar subqueries must be aggregated to return at most one row. | same error |
trino | 435 | Given correlated subquery is not supported | same error |
When src_tbl1 returns multiple rows, this SQL won't be executable. Hive/Spark/Trino disallow this syntax at parsing phase. MySQL/Postgres postpone throwing exception until execution and would allow if the subquery returns 1 row at execution time.
Generally speaking, I think it's a very narrow use case. And it requires a lot of change to sqllineage (we might need to introduce the concept of lexical scope, like Python doing variable lookup from local -> enclosed -> global -> built-in). That's error-prune and not adding too much value.
from sqllineage.
Our SQL does not have this kind of syntax. I just found this syntax when looking at the underlying sqlfluff, so I brought it up. Can be processed or not.
from sqllineage.
OK. We'll keep it open and take it as low priority then.
from sqllineage.
Related Issues (20)
- Subquery Partial Wildcard expansion breaks the column lineage path HOT 3
- Greenplum LATERAL Subquery doesn't work HOT 2
- False negative for Scalar Subquery used in Function HOT 2
- "function lineage" HOT 1
- question about column-level lineage: column in group by clause HOT 1
- “SELECT *” can not map real table name, but alias name.
- Installing from source without `npm` HOT 1
- `SQLAlchemy` optional dependency HOT 3
- Qualify Clause Parsing Failure HOT 1
- SQLfluff Not read nested configs. HOT 1
- UNION * Fails to resolve subsequent column lineage in UNION clause
- SELECT * from CTE fails to resolve column lineage
- add del something about temporary table‘s lineage
- When parsing a segment of SQL, although the field-level relationships exist, the source table information is lost.
- insert into db.tbl_z select * from db.tbl_x with MetaDataProvider error
- `lateral view explode` missing relationship
- Bug when Getting column lineage on Teradata with intermediate tables
- clickhouse <rename> not handled
- Parse stored procedures using sqllineage HOT 6
- Upgrade `sqlfluff` dependency to 3.1.0+
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sqllineage.