Uploaded image for project: 'Hive'
  1. Hive
  2. HIVE-8330

HiveResultSet.findColumn() parameters are case sensitive

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 0.13.1
    • 1.0.2, 1.1.0
    • None
    • None
    • HiveResultSet.findColumn() was case sensitive which is non-standard. This has been fixed.

    Description

      Look at the following code:

      Class.forName("org.apache.hive.jdbc.HiveDriver");
      
              Connection db = null;
              Statement stmt = null;
              ResultSet rs = null;
              try {
                  db = DriverManager.getConnection("jdbc:hive2://localhost:10000/default", "hive", "");
                  stmt = db.createStatement();
                  rs = stmt.executeQuery("SELECT * FROM sample_07 limit 1");
      
                  ResultSetMetaData metaData = rs.getMetaData();
                  for (int i = 1; i <= metaData.getColumnCount(); i++) {
                      System.out.println("Column " + i + ": " + metaData.getColumnName(i));
                  }
      
                  while (rs.next()) {
                      System.out.println(rs.findColumn("code"));
                  }
              } finally {
                  DbUtils.closeQuietly(db, stmt, rs);
              }
      

      Above program will generate following result on my cluster:

      Column 1: code
      Column 2: description
      Column 3: total_emp
      Column 4: salary
      1
      

      However, if the last print sentence is changed as following (using uppercase characters):

      System.out.println(rs.findColumn("Code"));
      

      The program will fail at exactly that line. The same happens if the column name is changed as "CODE"

      Based on the JDBC ResultSet documentation, this method should be case insensitive.

      "Column names used as input to getter methods are case insensitive"
      http://docs.oracle.com/javase/7/docs/api/java/sql/ResultSet.html

      Attachments

        1. HIVE-8330.1.patch
          1 kB
          Sergio Peña
        2. HIVE-8330.2.patch
          4 kB
          Sergio Peña
        3. HIVE-8330.3.patch
          5 kB
          Sergio Peña
        4. HIVE-8330.4.patch
          5 kB
          Sergio Peña

        Activity

          People

            spena Sergio Peña
            spena Sergio Peña
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: