alamb commented on code in PR #12222:
URL: https://github.com/apache/datafusion/pull/12222#discussion_r1757441089


##########
datafusion/sql/src/expr/value.rs:
##########
@@ -196,127 +195,42 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
             );
         }
 
-        // Only handle string exprs for now

Review Comment:
   It is great to remove all this stuff from the sql planner (as it is now in 
the parser)



##########
datafusion/sqllogictest/test_files/interval_mysql.slt:
##########
@@ -0,0 +1,71 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+
+#   http://www.apache.org/licenses/LICENSE-2.0
+
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Use `interval` SQL literal syntax with MySQL dialect
+
+# this should fail with the generic dialect
+query error DataFusion error: Error during planning: Cannot coerce arithmetic 
expression Interval\(MonthDayNano\) \+ Utf8 to valid types

Review Comment:
   I believe technically this is a regression in that this query used to work. 
   
   However, as this PR shows, it works in a different dialect
   
   I think it would be possible to add coercion rules to automatically coerce 
the `Utf8` to Interval to make this query continue work. I can file a follow on 
ticket
   
   



##########
datafusion/sqllogictest/test_files/interval_mysql.slt:
##########
@@ -0,0 +1,71 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+
+#   http://www.apache.org/licenses/LICENSE-2.0
+
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Use `interval` SQL literal syntax with MySQL dialect
+
+# this should fail with the generic dialect
+query error DataFusion error: Error during planning: Cannot coerce arithmetic 
expression Interval\(MonthDayNano\) \+ Utf8 to valid types

Review Comment:
   I double checked and this works today in datafusion-cli so this is 
technically a regression in functionality
   
   ```shell
   andrewlamb@Andrews-MacBook-Pro-2:~/Software/influxdb_iox$ datafusion-cli
   DataFusion CLI v41.0.0
   > select interval '1' + '1' month;
   
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | IntervalMonthDayNano("IntervalMonthDayNano { months: 1, days: 0, 
nanoseconds: 0 }") + IntervalMonthDayNano("IntervalMonthDayNano { months: 1, 
days: 0, nanoseconds: 0 }") |
   
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | 2 mons                                                                     
                                                                                
               |
   
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   1 row(s) fetched.
   Elapsed 0.008 seconds.
   ```



##########
datafusion/sqllogictest/test_files/expr.slt:
##########
@@ -1381,6 +1391,11 @@ SELECT extract(microsecond from 
arrow_cast('23:32:50.123456789'::time, 'Time64(N
 ----
 50123456.789000005
 
+query R

Review Comment:
   🎉 



##########
datafusion/sql/tests/cases/plan_to_sql.rs:
##########
@@ -495,11 +495,17 @@ fn test_table_references_in_plan_to_sql() {
         assert_eq!(format!("{}", sql), expected_sql)
     }
 
-    test("catalog.schema.table", "SELECT catalog.\"schema\".\"table\".id, 
catalog.\"schema\".\"table\".\"value\" FROM catalog.\"schema\".\"table\"");
-    test("schema.table", "SELECT \"schema\".\"table\".id, 
\"schema\".\"table\".\"value\" FROM \"schema\".\"table\"");
+    test(

Review Comment:
   this is a driveby (unrelated) cleanup, right? (this is fine I am just 
verifying my understanding)



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to