You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/04/13 18:10:31 UTC

[GitHub] [arrow-datafusion] alamb commented on a diff in pull request #2211: fix: ‘Invalid identifier #xxx’ caused by Case-to-case conversion in SQL

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


##########
datafusion/core/tests/sql/select.rs:
##########
@@ -1001,3 +1001,41 @@ async fn query_empty_table() {
     let expected = vec!["++", "++"];
     assert_batches_sorted_eq!(expected, &result);
 }
+
+#[tokio::test]
+async fn case_insensitive_in_sql() -> Result<()> {
+    // Test that field name and table name in sql is case-insensitive
+    let fields = vec![
+        Field::new("Column1", DataType::Utf8, true),

Review Comment:
   This table has schema equivalent to doing the following (note the `"` are very important as they say to not normalize case):
   
   ```sql
   CREATE TABLE test(
     "Column1" varchar,
     "COLUMN2" varchar,
     "column3" varchar
   )
   ```
   
   And in that case, I would expect 
   
   ```sql
   "SELECT COLumn1, colUMN2, column3 FROM test WHERE TEst.COLUMN1='content1' and column2='content2' and COLumn3='content3'"
   ``` 
   
   to fail. And in fact it does in postgres:
   
   ```sql
   alamb=# CREATE TABLE test(
     "Column1" varchar,
     "COLUMN2" varchar,
     "column3" varchar
   );
   CREATE TABLE
   alamb=# SELECT COLumn1, colUMN2, column3 FROM test WHERE TEst.COLUMN1='content1' and column2='content2' and COLumn3='content3';
   ERROR:  column "column1" does not exist
   LINE 1: SELECT COLumn1, colUMN2, column3 FROM test WHERE TEst.COLUMN...
                  ^
   HINT:  Perhaps you meant to reference the column "test.Column1" or the column "test.column3".
   alamb=# 
   
   ```



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