[ https://issues.apache.org/jira/browse/HIVE-18477?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Venu Yanamandra updated HIVE-18477: ----------------------------------- Description: When view is created via JDBC, white spaces are included in the view creation. This is not the same behavior if we use beeline to create the view. For the JDBC issue, consider the below tables setup. {code:java} create table t0 (id int, name string, address string, dob timestamp); create table t1 (id int, activity string, timedone timestamp); create table t2 (id int, history string); {code} And, the Java code to create the view: {code:java} public class ViewCreationThroughJDBC{ public static void main(String[] args) throws SQLException{ try { Class.forName("org.apache.hive.jdbc.HiveDriver"); } catch (ClassNotFoundException e) { e.printStackTrace(); System.exit(1); } String hostName = null; try { InetAddress ipAddress = InetAddress.getLocalHost(); hostName = ipAddress.getHostName(); System.out.println("Current IP: <" + ipAddress + ">"); System.out.println("Hostname is: <" + hostName + ">"); } catch (UnknownHostException e) { e.printStackTrace(); } String sql = null; try { sql = new String(Files.readAllBytes(Paths.get("view_create.txt")), StandardCharsets.UTF_8); } catch (Exception e) { e.printStackTrace(); } Connection conn = DriverManager.getConnection("jdbc:hive2://" + hostName + ":10000/default;", "username", "password"); Statement stmt = conn.createStatement(); System.out.println("Running: " + sql); //ResultSet res = stmt.executeQuery(sql); stmt.execute(sql); try { //res.close(); stmt.close(); conn.close(); } catch (Exception e) { e.printStackTrace(); } } } {code} And, the contents of view_create.txt referenced in the above code is as shown below: {code:java} create view v0 as select -- get the id from t0 table a.id -- Do not get --, any other --, details -- lets gather name address and dob , a.name , a.address , a.dob , b.activity , b.timedone -- The column name should be timezone and not timedone , c.history from t0 a, t1 b, t2 c where a.id = b.id and c.id = a.id {code} When this code is run and a 'show create table v0' is run from beeline, it shows empty lines. Essentially, when: 'show create table v0' is run from beeline, below is the output I see: {code:java} +------------------------------------------+--+ | createtab_stmt | +------------------------------------------+--+ | CREATE VIEW `v0` AS select | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | +------------------------------------------+--+ 22 rows selected (0.188 seconds){code} was: When view is created via JDBC, white spaces are included in the view creation. This is not the same behavior if we use beeline to create the view. For the JDBC issue, consider the below tables setup. {code} create table t0 (id int, name string, address string, dob timestamp); create table t1 (id int, activity string, timedone timestamp); create table t2 (id int, history string); {code} And, the Java code to create the view: {code} public class ViewCreationThroughJDBC{ public static void main(String[] args) throws SQLException{ try { Class.forName("org.apache.hive.jdbc.HiveDriver"); } catch (ClassNotFoundException e) { e.printStackTrace(); System.exit(1); } String hostName = null; try { InetAddress ipAddress = InetAddress.getLocalHost(); hostName = ipAddress.getHostName(); System.out.println("Current IP: <" + ipAddress + ">"); System.out.println("Hostname is: <" + hostName + ">"); } catch (UnknownHostException e) { e.printStackTrace(); } String sql = null; try { sql = new String(Files.readAllBytes(Paths.get("view_create.txt")), StandardCharsets.UTF_8); } catch (Exception e) { e.printStackTrace(); } Connection conn = DriverManager.getConnection("jdbc:hive2://" + hostName + ":10000/default;", "username", "password"); Statement stmt = conn.createStatement(); System.out.println("Running: " + sql); //ResultSet res = stmt.executeQuery(sql); stmt.execute(sql); try { //res.close(); stmt.close(); conn.close(); } catch (Exception e) { e.printStackTrace(); } } } {code} And, the contents of view_create.txt referenced in the above code is as shown below: {code} create view v0 as select -- get the id from t0 table a.id -- Do not get --, any other --, details -- lets gather name address and dob , a.name , a.address , a.dob , b.activity , b.timedone -- The column name should be timezone and not timedone , c.history from t0 a, t1 b, t2 c where a.id = b.id and c.id = a.id {code} When this code is run and a 'show create table v0' is run from beeline, it shows empty lines. > White spaces characters in view creation via JDBC cause problems with show > create. > ---------------------------------------------------------------------------------- > > Key: HIVE-18477 > URL: https://issues.apache.org/jira/browse/HIVE-18477 > Project: Hive > Issue Type: Bug > Components: JDBC > Affects Versions: 1.1.1 > Reporter: Venu Yanamandra > Priority: Minor > > When view is created via JDBC, white spaces are included in the view > creation. This is not the same behavior if we use beeline to create the view. > For the JDBC issue, consider the below tables setup. > {code:java} > create table t0 (id int, name string, address string, dob timestamp); > create table t1 (id int, activity string, timedone timestamp); > create table t2 (id int, history string); > {code} > And, the Java code to create the view: > {code:java} > public class ViewCreationThroughJDBC{ > public static void main(String[] args) throws SQLException{ > try { > Class.forName("org.apache.hive.jdbc.HiveDriver"); > } catch (ClassNotFoundException e) { > e.printStackTrace(); > System.exit(1); > } > String hostName = null; > try { > InetAddress ipAddress = InetAddress.getLocalHost(); > hostName = ipAddress.getHostName(); > System.out.println("Current IP: <" + ipAddress + ">"); > System.out.println("Hostname is: <" + hostName + ">"); > } catch (UnknownHostException e) { > e.printStackTrace(); > } > String sql = null; > try { > sql = new String(Files.readAllBytes(Paths.get("view_create.txt")), > StandardCharsets.UTF_8); > } catch (Exception e) { > e.printStackTrace(); > } > Connection conn = DriverManager.getConnection("jdbc:hive2://" + hostName + > ":10000/default;", "username", "password"); > Statement stmt = conn.createStatement(); > System.out.println("Running: " + sql); > //ResultSet res = stmt.executeQuery(sql); > stmt.execute(sql); > try { > //res.close(); > stmt.close(); > conn.close(); > } > catch (Exception e) { > e.printStackTrace(); > } > } > } > {code} > And, the contents of view_create.txt referenced in the above code is as shown > below: > {code:java} > create view v0 as > select > -- get the id from t0 table > a.id > -- Do not get > --, any other > --, details > -- lets gather name address and dob > , > a.name , > a.address , > a.dob , > b.activity , > b.timedone > -- The column name should be timezone and not timedone > , > c.history > from t0 a, t1 b, t2 c > where > a.id = b.id > and c.id = a.id > {code} > When this code is run and a 'show create table v0' is run from beeline, it > shows empty lines. > Essentially, when: 'show create table v0' is run from beeline, below is the > output I see: > {code:java} > +------------------------------------------+--+ > | createtab_stmt | > +------------------------------------------+--+ > | CREATE VIEW `v0` AS select | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > +------------------------------------------+--+ > 22 rows selected (0.188 seconds){code} -- This message was sent by Atlassian JIRA (v7.6.3#76005)