kasakrisz commented on code in PR #4557:
URL: https://github.com/apache/hive/pull/4557#discussion_r1295763804


##########
itests/hive-unit/src/test/java/org/apache/hive/beeline/TestHplSqlViaBeeLine.java:
##########
@@ -610,6 +610,25 @@ public void testNullCast() throws Throwable {
     testScriptFile(SCRIPT_TEXT, args(), "^(.(?!(NullPointerException)))*$", 
OutStream.ERR);
   }
 
+  @Test
+  public void testTableAliasInColumnName() throws Throwable {
+    String SCRIPT_TEXT =
+            "DROP TABLE IF EXISTS input;\n" +
+            "DROP TABLE IF EXISTS result;\n" +
+            "CREATE TABLE input (col1 string, col2 int);\n" +
+            "CREATE TABLE result (res string);\n" +
+            "INSERT INTO input VALUES('Hive', 3);\n" +
+            "CREATE PROCEDURE p1() AS\n" +
+            "BEGIN\n" +
+            "FOR rec IN (select tab.col1, tab.col2 num from input tab) LOOP\n" 
+

Review Comment:
   Is quoted identifiers supported?
   ```
   "FOR rec IN (select `input tab`.`the first column`, `input tab`.col2 num 
from `some input table` `input tab`) LOOP\n" +
   ```



##########
hplsql/src/main/java/org/apache/hive/hplsql/ColumnMap.java:
##########
@@ -28,13 +28,25 @@ public class ColumnMap {
   private List<Column> columns = new ArrayList<>();
   private Map<String, Column> columnMap = new HashMap<>();
 
+  private Map<String, String> columnNameVsFQColumnName = new HashMap<>();
+
   public void add(Column column) {
     columns.add(column);
-    columnMap.put(column.getName().toUpperCase(), column);
+    String columnName = column.getName().toUpperCase();
+    columnMap.put(columnName, column);
+    if (columnName.contains(".")) {

Review Comment:
   '.' is a valid character in a quoted identifier.
   
https://github.com/apache/hive/blob/e4348422c6f3b1910a8600ea7c7bd839894dcd6f/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/utils/MetaStoreUtils.java#L131-L137
   (above characters are accepted in any identifier not just in table names)
   
   Can we have a separate field for table/alias name in the `Column` class?



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