You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "alamb (via GitHub)" <gi...@apache.org> on 2023/02/01 14:32:53 UTC

[GitHub] [arrow-datafusion] alamb commented on a diff in pull request #5124: Add option to control whether to normalize ident

alamb commented on code in PR #5124:
URL: https://github.com/apache/arrow-datafusion/pull/5124#discussion_r1093305220


##########
datafusion/sql/src/relation/mod.rs:
##########
@@ -33,7 +33,10 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
         let (plan, alias) = match relation {
             TableFactor::Table { name, alias, .. } => {
                 // normalize name and alias
-                let table_ref = object_name_to_table_reference(name)?;
+                let table_ref = object_name_to_table_reference(
+                    name,
+                    self.options.enable_ident_normalization,
+                )?;

Review Comment:
   This code could potentially be improved by making a `self.object_name_to_table_reference` rather than having to pass ` self.options.enable_ident_normalization,` at each callsite, but we can do that as a follow on PR



##########
datafusion/core/tests/sqllogictests/test_files/ddl.slt:
##########
@@ -465,3 +465,63 @@ query II rowsort
 select * from table_without_values;
 ----
 10 20
+
+# Enable information_schema, so we can execute show create table
+statement ok
+set datafusion.catalog.information_schema = true;
+
+statement ok
+CREATE OR REPLACE TABLE TABLE_WITH_NORMALIZATION(FIELD1 BIGINT, FIELD2 BIGINT);
+
+# Check table name is in lowercase
+query CCCC
+show create table table_with_normalization
+----
+datafusion public table_with_normalization NULL
+
+# Check column name is in uppercase
+query CCC
+describe table_with_normalization
+----
+field1 Int64 NO
+field2 Int64 NO
+
+# Disable ident normalization
+statement ok
+set datafusion.sql_parser.enable_ident_normalization = false;
+
+statement ok
+CREATE TABLE TABLE_WITHOUT_NORMALIZATION(FIELD1 BIGINT, FIELD2 BIGINT) AS VALUES (1,2);
+
+# Check table name is in uppercase
+query CCCC
+show create table TABLE_WITHOUT_NORMALIZATION
+----
+datafusion public TABLE_WITHOUT_NORMALIZATION NULL
+
+# Check column name is in uppercase
+query CCC
+describe TABLE_WITHOUT_NORMALIZATION
+----
+FIELD1 Int64 YES
+FIELD2 Int64 YES
+
+query R
+select 10000000000000000000.01
+----
+10000000000000000000
+
+statement ok
+set datafusion.sql_parser.parse_float_as_decimal = true;
+
+query R
+select 10000000000000000000.01
+----
+10000000000000000000.01

Review Comment:
   Another query you can do is `select arrow_typeof(10000000000000000000.01)` to see the actual type of the expression



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org