You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@tez.apache.org by Sateesh Karuturi <sa...@gmail.com> on 2015/08/04 17:22:09 UTC

getting mismatched input 'ROW' expecting error in hive creation

i want create a hive table using java code. my code is
package com.inndata.services;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Connection;
import java.sql.Statement;
import java.sql.DriverManager;
public class HiveCreateTable {
  private static String driverName =
"com.facebook.presto.jdbc.PrestoDriver";

  public static void main(String[] args) throws SQLException {

     // Register driver and create driver instance
     try {
        Class.forName(driverName);
    } catch (ClassNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
     System.out.println("haiiiiii");
     Connection con = DriverManager.getConnection("jdbc:
presto://192.168.1.118:8023", "hadoop", "cassandra");
     con.setCatalog("hive");
     con.setSchema("log");
     Statement stmt = con.createStatement();
     ResultSet res = stmt.executeQuery("create table access_log (c_ip
varchar,"
                                                                 +
"cs_username varchar,"
                                                                 +
"cs_computername varchar,"
                                                                 + "cs_date
varchar,"
                                                                 + "cs_code
varchar,"
                                                                 +
"cs_method varchar,"
                                                                 +
"cs_uri_stem varchar,"
                                                                 +
"cs_uri_query varchar,"
                                                                 +
"cs_status_code varchar,"
                                                                 +
"cs_bytes varchar)"
                                                                 + "ROW
 FORMAT DELIMITED FIELDS TERMINATED BY '\b' LINES TERMINATED BY '\n'");
     System.out.println("Table access_log created.");
     con.close();
  }
}
and getting
Exception in thread "main" java.sql.SQLException: Query failed
(#20150804_152058_00004_r8ehs): line 1:214: mismatched input 'ROW'
expecting <EOF>

Re: getting mismatched input 'ROW' expecting error in hive creation

Posted by gabriel balan <ga...@oracle.com>.
Hi
>  + "ROW  FORMAT DELIMITED FIELDS TERMINATED BY '\b' LINES TERMINATED BY '\n'");
Shouldn't you escape the backslashes ('\\n' instead of '\n'), so they're not interpreted by java?

hth
GB


On 8/4/2015 11:22 AM, Sateesh Karuturi wrote:
> i want create a hive table using java code. my code is
> package com.inndata.services;/
> /import java.sql.ResultSet;
> import java.sql.SQLException;
> import java.sql.Connection;
> import java.sql.Statement;
> import java.sql.DriverManager;/
> /public class HiveCreateTable {
> private static String driverName = "com.facebook.presto.jdbc.PrestoDriver";
>
> public static void main(String[] args) throws SQLException {
>
>    // Register driver and create driver instance
>    try {
>         Class.forName(driverName);
>     } catch (ClassNotFoundException e) {
>         // TODO Auto-generated catch block
>         e.printStackTrace();
>     }
>    System.out.println("haiiiiii");
>    Connection con = DriverManager.getConnection("jdbc:presto://192.168.1.118:8023", "hadoop", "cassandra");
>    con.setCatalog("hive");
>    con.setSchema("log");
>    Statement stmt = con.createStatement();
>    ResultSet res = stmt.executeQuery("create table access_log (c_ip varchar,"
>                                                              + "cs_username varchar,"
>                                                              + "cs_computername varchar,"
>                                                              + "cs_date varchar,"
>                                                              + "cs_code varchar,"
>                                                              + "cs_method varchar,"
>                                                              + "cs_uri_stem varchar,"
>                                                              + "cs_uri_query varchar,"
>                                                              + "cs_status_code varchar,"
>                                                              + "cs_bytes varchar)"
>                                                              + "ROW  FORMAT DELIMITED FIELDS TERMINATED BY '\b' LINES TERMINATED BY '\n'");
>    System.out.println("Table access_log created.");
>    con.close();
> }
> }
> and getting
> Exception in thread "main" java.sql.SQLException: Query failed (#20150804_152058_00004_r8ehs): line 1:214: mismatched input 'ROW' expecting <EOF>

-- 
The statements and opinions expressed here are my own and do not necessarily represent those of Oracle Corporation.