Uploaded image for project: 'CarbonData'
  1. CarbonData
  2. CARBONDATA-1461

Unable to Read Date And TimeStamp Type in HIve

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Trivial
    • Resolution: Fixed
    • 1.2.0
    • 1.2.0
    • hive-integration
    • None
    • hive1.21.,spark 2.1

    Description

      val connection = DriverManager.getConnection(s"jdbc:hive2://localhost:$port/default", "", "")
      val statement: Statement = connection.createStatement

      logger.info(s"============HIVE CLI IS STARTED ON PORT $port ==============")

      statement.execute("CREATE TABLE IF NOT EXISTS carbon_table(shortField SMALLINT,intField INT,bigintField " +
      "bigint,doubleField DOUBLE,stringField STRING,timestampField TIMESTAMP," +
      "decimalField DECIMAL(18,2),dateField DATE,\n charField CHAR(5),floatField " +
      "double,complexData ARRAY<STRING>)")
      statement
      .execute(
      "ALTER TABLE carbon_table SET FILEFORMAT INPUTFORMAT \"org.apache.carbondata." +
      "hive.MapredCarbonInputFormat\"OUTPUTFORMAT \"org.apache.carbondata.hive." +
      "MapredCarbonOutputFormat\"SERDE \"org.apache.carbondata.hive." +
      "CarbonHiveSerDe\" ")

      statement
      .execute(
      "ALTER TABLE carbon_table SET LOCATION 'file:///home/vinod/Desktop/carbondata/examples/spark2/target/store/default/carbon_table' ")

      val sql = "SELECT dateField FROM carbon_table"

      val resultSet: ResultSet = statement.executeQuery(sql)

      logs

      exception in thread "main" org.apache.hive.service.cli.HiveSQLException:
      java.io.IOException: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Long
      at org.apache.hive.jdbc.Utils.verifySuccess(Utils.java:256)
      at org.apache.hive.jdbc.Utils.verifySuccessWithInfo(Utils.java:242)
      at org.apache.hive.jdbc.HiveQueryResultSet.next(HiveQueryResultSet.java:365)

      when i tried to read timestamp type it gives error

      val sql = "SELECT timestampField FROM carbon_table"

      val resultSet: ResultSet = statement.executeQuery(sql)

      var rowsFetched = 0

      while (resultSet.next) {
      println("*****"+resultSet.getString("timestampField"))
      }

      java.lang.IllegalArgumentException: Timestamp format must be yyyy-mm-dd hh:mm:ss[.fffffffff]

      Attachments

        Issue Links

          Activity

            People

              anubhavtarar anubhav tarar
              anubhavtarar anubhav tarar
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 40m
                  40m