You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
scala> spark.sql("""SELECT __t404.__c394, __t404.__c395, __t404.__c396, __t404.__c397
| FROM ((
| (SELECT test1.c0 AS __c394, test1.c1 AS __c395, test1.c2 AS __c396, test1.c3 AS __c397
| FROM (test1)) __t398
| INNER JOIN
| (SELECT test1.c0 AS __c399, test1.c1 AS __c400, test1.c2 AS __c401, test1.c3 AS __c402
| FROM (test1)) __t403
| ON __t398.__c395 = __t403.__c401) __t404)
| WHERE __t404.__c395 != __t404.__c396""").show
+------+------+------+------+
|__c394|__c395|__c396|__c397|
+------+------+------+------+
+------+------+------+------+
use sqlparser::dialect::GenericDialect;use sqlparser::parser::Parser;fnmain(){let dialect = GenericDialect{};// or AnsiDialectlet sql = "SELECT __t404.__c394, __t404.__c395, __t404.__c396, __t404.__c397 FROM (( (SELECT test1.c0 AS __c394, test1.c1 AS __c395, test1.c2 AS __c396, test1.c3 AS __c397 FROM (test1)) __t398 INNER JOIN (SELECT test1.c0 AS __c399, test1.c1 AS __c400, test1.c2 AS __c401, test1.c3 AS __c402 FROM (test1)) __t403 ON __t398.__c395 = __t403.__c401) __t404) WHERE __t404.__c395 != __t404.__c396; ";let ast = Parser::parse_sql(&dialect, sql).unwrap();println!("AST: {:?}", ast);}
➜ sp git:(master) ✗ cargo run
Compiling sp v0.1.0 (/Users/willy/willy/df-workspace/sp)
Finished dev [unoptimized + debuginfo] target(s) in 0.30s
Running `target/debug/sp`
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: ParserError("Expected ), found: __t404")', src/main.rs:26:48
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
looks like the outer alias doesn't work. the following sql works
❯ SELECT __c394, __c395, __c396, __c397
FROM ((
(SELECTtest1.c0AS __c394, test1.c1AS __c395, test1.c2AS __c396, test1.c3AS __c397
FROM (test1)) __t398
INNER JOIN
(SELECTtest1.c0AS __c399, test1.c1AS __c400, test1.c2AS __c401, test1.c3AS __c402
FROM (test1)) __t403
ON__t398.__c395=__t403.__c401) )
WHERE __c395 != __c396;
0 rows inset. Query took 0.004 seconds.
Activity
waitingkuo commentedon Jul 10, 2022
i tried it on sqlparser-rs, it doesn't work
➜ sp git:(master) ✗ cargo run Compiling sp v0.1.0 (/Users/willy/willy/df-workspace/sp) Finished dev [unoptimized + debuginfo] target(s) in 0.30s Running `target/debug/sp` thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: ParserError("Expected ), found: __t404")', src/main.rs:26:48 note: run with `RUST_BACKTRACE=1` environment variable to display a backtracelooks like the outer alias doesn't work. the following sql works
waitingkuo commentedon Aug 3, 2022
@andygrove i've made the pull request to sqlparser-rs to make nestedjoin support alias
I will update this https://github.com/apache/arrow-datafusion/blob/master/datafusion/sql/src/planner.rs#L731 after new sqlparser released
waitingkuo commentedon Aug 8, 2022
@andygrove the parser error fixed in #3072
now it raised another error
I feel like this might have the similar issue as #3073
alamb commentedon Aug 22, 2024
This query seems to work great on datafusion 41.0.0