[ https://issues.apache.org/jira/browse/CARBONDATA-1477?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] cen yuhai updated CARBONDATA-1477: ---------------------------------- Description: {code} import org.apache.spark.sql.CarbonSession._ val carbonSession = SparkSession .builder() .master("local") .appName("HiveExample") .config("carbonSession.sql.warehouse.dir", warehouse).enableHiveSupport() .getOrCreateCarbonSession( store) carbonSession.sql("""DROP TABLE IF EXISTS HIVE_CARBON_EXAMPLE""".stripMargin) carbonSession .sql( """CREATE TABLE HIVE_CARBON_EXAMPLE (ID int,NAME string,SALARY double,JOININGDATE date) STORED BY |'CARBONDATA' """ .stripMargin) carbonSession.sql( s""" LOAD DATA LOCAL INPATH '$rootPath/integration/hive/src/main/resources/data.csv' INTO TABLE HIVE_CARBON_EXAMPLE """) carbonSession.sql("SELECT * FROM HIVE_CARBON_EXAMPLE").show() carbonSession.stop() try { Class.forName(driverName) } catch { case classNotFoundException: ClassNotFoundException => classNotFoundException.printStackTrace() } HiveEmbeddedServer.start() val port = HiveEmbeddedServer.getFreePort val connection = DriverManager.getConnection(s"jdbc:hive2://localhost:8000/default", "", "") val statement: Statement = connection.createStatement logger.info(s"============HIVE CLI IS STARTED ON PORT $port ==============") statement.execute("CREATE TABLE IF NOT EXISTS " + "HIVE_CARBON_EXAMPLE " + " (ID int, NAME string,SALARY double,JOININGDATE date)") statement .execute( "ALTER TABLE HIVE_CARBON_EXAMPLE SET FILEFORMAT INPUTFORMAT \"org.apache.carbondata." + "hive.MapredCarbonInputFormat\"OUTPUTFORMAT \"org.apache.carbondata.hive." + "MapredCarbonOutputFormat\"SERDE \"org.apache.carbondata.hive." + "CarbonHiveSerDe\" ") statement .execute( "ALTER TABLE HIVE_CARBON_EXAMPLE SET LOCATION " + s"'file:///$store/default/hive_carbon_example' ") val sql = "SELECT * FROM HIVE_CARBON_EXAMPLE" val resultSet: ResultSet = statement.executeQuery(sql) var rowsFetched = 0 while (resultSet.next) { println("*********"+resultSet.getString("JOININGDATE")) } println(s"******Total Number Of Rows Fetched ****** $rowsFetched") logger.info("Fetching the Individual Columns ") HiveEmbeddedServer.stop() {code} actual result *********null *********1970-01-01 values in my csv are ID,NAME,SALARY,JOININGDATE 1,'liang',200000,2016-03-14 2,'anubhav',20000,2019/03/17 was: import org.apache.spark.sql.CarbonSession._ val carbonSession = SparkSession .builder() .master("local") .appName("HiveExample") .config("carbonSession.sql.warehouse.dir", warehouse).enableHiveSupport() .getOrCreateCarbonSession( store) carbonSession.sql("""DROP TABLE IF EXISTS HIVE_CARBON_EXAMPLE""".stripMargin) carbonSession .sql( """CREATE TABLE HIVE_CARBON_EXAMPLE (ID int,NAME string,SALARY double,JOININGDATE date) STORED BY |'CARBONDATA' """ .stripMargin) carbonSession.sql( s""" LOAD DATA LOCAL INPATH '$rootPath/integration/hive/src/main/resources/data.csv' INTO TABLE HIVE_CARBON_EXAMPLE """) carbonSession.sql("SELECT * FROM HIVE_CARBON_EXAMPLE").show() carbonSession.stop() try { Class.forName(driverName) } catch { case classNotFoundException: ClassNotFoundException => classNotFoundException.printStackTrace() } HiveEmbeddedServer.start() val port = HiveEmbeddedServer.getFreePort val connection = DriverManager.getConnection(s"jdbc:hive2://localhost:8000/default", "", "") val statement: Statement = connection.createStatement logger.info(s"============HIVE CLI IS STARTED ON PORT $port ==============") statement.execute("CREATE TABLE IF NOT EXISTS " + "HIVE_CARBON_EXAMPLE " + " (ID int, NAME string,SALARY double,JOININGDATE date)") statement .execute( "ALTER TABLE HIVE_CARBON_EXAMPLE SET FILEFORMAT INPUTFORMAT \"org.apache.carbondata." + "hive.MapredCarbonInputFormat\"OUTPUTFORMAT \"org.apache.carbondata.hive." + "MapredCarbonOutputFormat\"SERDE \"org.apache.carbondata.hive." + "CarbonHiveSerDe\" ") statement .execute( "ALTER TABLE HIVE_CARBON_EXAMPLE SET LOCATION " + s"'file:///$store/default/hive_carbon_example' ") val sql = "SELECT * FROM HIVE_CARBON_EXAMPLE" val resultSet: ResultSet = statement.executeQuery(sql) var rowsFetched = 0 while (resultSet.next) { println("*********"+resultSet.getString("JOININGDATE")) } println(s"******Total Number Of Rows Fetched ****** $rowsFetched") logger.info("Fetching the Individual Columns ") HiveEmbeddedServer.stop() actual result *********null *********1970-01-01 values in my csv are ID,NAME,SALARY,JOININGDATE 1,'liang',200000,2016-03-14 2,'anubhav',20000,2019/03/17 > wrong values shown when fetching date type values in hive > --------------------------------------------------------- > > Key: CARBONDATA-1477 > URL: https://issues.apache.org/jira/browse/CARBONDATA-1477 > Project: CarbonData > Issue Type: Bug > Components: hive-integration > Affects Versions: 1.2.0 > Environment: hive1.2.1,spark2.1 > Reporter: anubhav tarar > Assignee: anubhav tarar > Priority: Trivial > Time Spent: 40m > Remaining Estimate: 0h > > {code} > import org.apache.spark.sql.CarbonSession._ > val carbonSession = SparkSession > .builder() > .master("local") > .appName("HiveExample") > .config("carbonSession.sql.warehouse.dir", warehouse).enableHiveSupport() > .getOrCreateCarbonSession( > store) > carbonSession.sql("""DROP TABLE IF EXISTS HIVE_CARBON_EXAMPLE""".stripMargin) > carbonSession > .sql( > """CREATE TABLE HIVE_CARBON_EXAMPLE (ID int,NAME string,SALARY double,JOININGDATE date) STORED BY > |'CARBONDATA' """ > .stripMargin) > carbonSession.sql( > s""" > LOAD DATA LOCAL INPATH '$rootPath/integration/hive/src/main/resources/data.csv' INTO > TABLE > HIVE_CARBON_EXAMPLE > """) > carbonSession.sql("SELECT * FROM HIVE_CARBON_EXAMPLE").show() > carbonSession.stop() > try { > Class.forName(driverName) > } > catch { > case classNotFoundException: ClassNotFoundException => > classNotFoundException.printStackTrace() > } > HiveEmbeddedServer.start() > val port = HiveEmbeddedServer.getFreePort > val connection = DriverManager.getConnection(s"jdbc:hive2://localhost:8000/default", "", "") > val statement: Statement = connection.createStatement > logger.info(s"============HIVE CLI IS STARTED ON PORT $port ==============") > statement.execute("CREATE TABLE IF NOT EXISTS " + "HIVE_CARBON_EXAMPLE " + > " (ID int, NAME string,SALARY double,JOININGDATE date)") > statement > .execute( > "ALTER TABLE HIVE_CARBON_EXAMPLE SET FILEFORMAT INPUTFORMAT \"org.apache.carbondata." + > "hive.MapredCarbonInputFormat\"OUTPUTFORMAT \"org.apache.carbondata.hive." + > "MapredCarbonOutputFormat\"SERDE \"org.apache.carbondata.hive." + > "CarbonHiveSerDe\" ") > statement > .execute( > "ALTER TABLE HIVE_CARBON_EXAMPLE SET LOCATION " + > s"'file:///$store/default/hive_carbon_example' ") > val sql = "SELECT * FROM HIVE_CARBON_EXAMPLE" > val resultSet: ResultSet = statement.executeQuery(sql) > var rowsFetched = 0 > while (resultSet.next) { > println("*********"+resultSet.getString("JOININGDATE")) > } > println(s"******Total Number Of Rows Fetched ****** $rowsFetched") > logger.info("Fetching the Individual Columns ") > HiveEmbeddedServer.stop() > {code} > actual result > *********null > *********1970-01-01 > values in my csv are > ID,NAME,SALARY,JOININGDATE > 1,'liang',200000,2016-03-14 > 2,'anubhav',20000,2019/03/17 -- This message was sent by Atlassian JIRA (v6.4.14#64029) |
Free forum by Nabble | Edit this page |