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

DatabaseMetadata.getColumn returns precision 0 for varchar/decimal

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Won't Fix
    • Affects Version/s: 0.14.0
    • Fix Version/s: 0.14.1
    • Component/s: JDBC
    • Labels:
      None

      Description

      I hit same error as HIVE-5847 and HIVE-10933. JDBC version is hive-jdbc-0.14.0.2.2.4.2-2-standalone.jar.

      My test program as below:
      /*************************************** test.java **********************************************/
      import java.sql.SQLException;
      import java.sql.Connection;
      import java.sql.ResultSet;
      import java.sql.Statement;
      import java.sql.DriverManager;
      import java.lang.*;
      import java.sql.DatabaseMetaData;
      import java.sql.ResultSetMetaData;

      public class test {
      private static String driverName = "org.apache.hive.jdbc.HiveDriver";

      /**

      • @param args
      • @throws SQLException
        */
        public static void main(String[] args) throws SQLException {
        try { Class.forName(driverName); }

        catch (ClassNotFoundException e)

        { // TODO Auto-generated catch block e.printStackTrace(); System.exit(1); }

        //replace "hive" here with the name of the user the queries should run as
        Connection con = DriverManager.getConnection("jdbc:hive2://<hive_server_address>:10001/default", "hadoop", "");
        Statement stmt = con.createStatement();
        String tableName = "test";
        stmt.execute("drop table if exists " + tableName);
        stmt.execute("create table " + tableName + " (key varchar(10)) row format delimited fields terminated by '\t'");

      ResultSet res = con.getMetaData().getColumns(null, "default", "test", null);
      while (res.next())

      { System.out.println("COLUMN_NAME: " + res.getString(4)); System.out.println("COLUMN_PRECISION: " + res.getString(7)); }

      }
      }

      Resutl
      ------------------
      COLUMN_NAME: key
      COLUMN_PRECISION: null

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              yaqiong_liu Yaqiong
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 96h
                96h
                Remaining:
                Remaining Estimate - 96h
                96h
                Logged:
                Time Spent - Not Specified
                Not Specified