andygrove opened a new issue, #2867:
URL: https://github.com/apache/arrow-datafusion/issues/2867

   **Describe the bug**
   I am working on a SQL query fuzzer (see 
[sqlfuzz](https://crates.io/crates/sqlfuzz) crate) and I think it just found a 
bug in DataFusion. 
   
   The following SQL works fine in Spark but fails in DataFusion with 
`ParserError("Expected ), found: __t404")`.
   
   ```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
   ```
   
   Spark:
   
   ```
   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|
   +------+------+------+------+
   +------+------+------+------+
   ```
   
   **To Reproduce**
   Use sqlfuzz
   
   **Expected behavior**
   Query should work
   
   **Additional context**
   None
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to