@Test
  public void testTableAliasInColumnName() throws Throwable {
    String scriptText =
        "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', 2023);\n" +
            "CREATE PROCEDURE p1() AS\n" +
            "  BEGIN\n" +
            "    FOR rec IN (select tab.col1, tab.col2 num from input tab) LOOP\n" +
            "      INSERT INTO result VALUES(rec.num || ' = ' || rec.col1);\n" +
            "  END LOOP;\n" +
            "END;\n" +
            "p1();\n" +
            "SELECT * FROM result;\n";
    testScriptFile(scriptText, args(), "2023 = Hive");
  }
Start up a local Hive Server 2 for these tests
itests/hive-unit/src/test/java/org/apache/hive/beeline/TestHplSqlViaBeeLine.java