You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by ha...@apache.org on 2014/04/22 18:20:03 UTC

svn commit: r1589197 - in /hive/trunk/beeline/src/java/org/apache/hive/beeline: HiveSchemaHelper.java HiveSchemaTool.java

Author: hashutosh
Date: Tue Apr 22 16:20:03 2014
New Revision: 1589197

URL: http://svn.apache.org/r1589197
Log:
HIVE-6927 : Add support for MSSQL in schematool (Deepesh Khandelwal via Ashutosh Chauhan)

Modified:
    hive/trunk/beeline/src/java/org/apache/hive/beeline/HiveSchemaHelper.java
    hive/trunk/beeline/src/java/org/apache/hive/beeline/HiveSchemaTool.java

Modified: hive/trunk/beeline/src/java/org/apache/hive/beeline/HiveSchemaHelper.java
URL: http://svn.apache.org/viewvc/hive/trunk/beeline/src/java/org/apache/hive/beeline/HiveSchemaHelper.java?rev=1589197&r1=1589196&r2=1589197&view=diff
==============================================================================
--- hive/trunk/beeline/src/java/org/apache/hive/beeline/HiveSchemaHelper.java (original)
+++ hive/trunk/beeline/src/java/org/apache/hive/beeline/HiveSchemaHelper.java Tue Apr 22 16:20:03 2014
@@ -21,6 +21,7 @@ import java.util.IllegalFormatException;
 
 public class HiveSchemaHelper {
   public static final String DB_DERBY = "derby";
+  public static final String DB_MSSQL = "mssql";
   public static final String DB_MYSQL = "mysql";
   public static final String DB_POSTGRACE = "postgres";
   public static final String DB_ORACLE = "oracle";
@@ -251,9 +252,29 @@ public class HiveSchemaHelper {
     }
   }
 
+  //MSSQL specific parser
+  public static class MSSQLCommandParser extends AbstractCommandParser {
+    private static String MSSQL_NESTING_TOKEN = ":r";
+    @Override
+    public String getScriptName(String dbCommand) throws IllegalArgumentException {
+      String[] tokens = dbCommand.split(" ");
+      if (tokens.length != 2) {
+        throw new IllegalArgumentException("Couldn't parse line " + dbCommand);
+      }
+      return tokens[1];
+    }
+
+    @Override
+    public boolean isNestedScript(String dbCommand) {
+      return dbCommand.startsWith(MSSQL_NESTING_TOKEN);
+    }
+  }
+
   public static NestedScriptParser getDbCommandParser(String dbName) {
     if (dbName.equalsIgnoreCase(DB_DERBY)) {
       return new DerbyCommandParser();
+    } else if (dbName.equalsIgnoreCase(DB_MSSQL)) {
+      return new MSSQLCommandParser();
     } else if (dbName.equalsIgnoreCase(DB_MYSQL)) {
       return new MySqlCommandParser();
     } else if (dbName.equalsIgnoreCase(DB_POSTGRACE)) {

Modified: hive/trunk/beeline/src/java/org/apache/hive/beeline/HiveSchemaTool.java
URL: http://svn.apache.org/viewvc/hive/trunk/beeline/src/java/org/apache/hive/beeline/HiveSchemaTool.java?rev=1589197&r1=1589196&r2=1589197&view=diff
==============================================================================
--- hive/trunk/beeline/src/java/org/apache/hive/beeline/HiveSchemaTool.java (original)
+++ hive/trunk/beeline/src/java/org/apache/hive/beeline/HiveSchemaTool.java Tue Apr 22 16:20:03 2014
@@ -454,6 +454,7 @@ public class HiveSchemaTool {
     if (line.hasOption("dbType")) {
       dbType = line.getOptionValue("dbType");
       if ((!dbType.equalsIgnoreCase(HiveSchemaHelper.DB_DERBY) &&
+          !dbType.equalsIgnoreCase(HiveSchemaHelper.DB_MSSQL) &&
           !dbType.equalsIgnoreCase(HiveSchemaHelper.DB_MYSQL) &&
           !dbType.equalsIgnoreCase(HiveSchemaHelper.DB_POSTGRACE) && !dbType
           .equalsIgnoreCase(HiveSchemaHelper.DB_ORACLE))) {