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 15:54:09 UTC

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

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


##########
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),
+        Field::new("COLUMN2", DataType::Utf8, true),
+        Field::new("column3", DataType::Utf8, true),
+    ];
+    let schema = Schema::new(fields);
+    let a = StringArray::from(vec!["content1"]);
+    let b = StringArray::from(vec!["content2"]);
+    let c = StringArray::from(vec!["content3"]);
+    let record_batch = RecordBatch::try_new(
+        Arc::new(schema),
+        vec![Arc::new(a), Arc::new(b), Arc::new(c)],
+    )
+    .unwrap();
+    let table =
+        MemTable::try_new(record_batch.schema(), vec![vec![record_batch]]).unwrap();
+
+    let ctx = SessionContext::new();
+    ctx.register_table("test", Arc::new(table))?;
+
+    // Select with lower and upper case
+    let sql = "SELECT COLumn1,colUMN2,column3 FROM test where TEst.COLUMN1='content1' and column2='content2' and COLumn3='content3'";

Review Comment:
   minor change
   ```suggestion
       let sql = "SELECT COLumn1, colUMN2, column3 FROM test WHERE TEst.COLUMN1='content1' and column2='content2' and COLumn3='content3'";
   ```



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