Skip to content
Snippets Groups Projects
Commit 5b62b4aa authored by Julien Lopez's avatar Julien Lopez
Browse files

Add support for Hive

parent fc0071b6
No related branches found
No related tags found
No related merge requests found
......@@ -5,6 +5,7 @@ import java.util.Map;
import qir.ast.*;
import qir.ast.data.*;
import qir.driver.hbase.HBaseDriver;
import qir.driver.sql.QIRHiveDriver;
import qir.driver.sql.OracleDriver;
import qir.driver.sql.PostgreSQLDriver;
import qir.util.QIRException;
......@@ -49,6 +50,9 @@ public abstract class DBDriver<DBRepr> {
case "PostgreSQL":
result = new PostgreSQLDriver(fileName);
break;
case "Hive":
result = new QIRHiveDriver(fileName);
break;
case "HBase":
result = new HBaseDriver(fileName);
break;
......
package qir.driver.sql;
import java.sql.*;
import qir.util.QIRException;
/**
* {@link QIRHiveDriver} is an intermediate between QIR and a PostgreSQL database.
*/
public final class QIRHiveDriver extends SQLStringDriver {
public QIRHiveDriver(final String newConfigFile) {
super(newConfigFile);
}
@Override
public final void openConnection(final String newConfigFile) throws QIRException {
try {
super.openConnection(newConfigFile);
conn = DriverManager.getConnection("jdbc:hive2://" + config.serverName + ":" + config.portNumber + "/" + config.sid, "hive", "");
} catch (final SQLException e) {
e.printStackTrace();
throw new QIRException("Could not open connection to Hive database: " + config.serverName);
}
}
}
\ No newline at end of file
......@@ -93,7 +93,7 @@ abstract class SQLStringDriver extends SQLDriver<String> {
data = new QIRString(null, rs.getString(i));
break;
}
newTuple = new QIRTcons(null, rs.getMetaData().getColumnLabel(i), data, newTuple);
newTuple = new QIRTcons(null, rs.getMetaData().getColumnLabel(i).replaceFirst(".*\\.", ""), data, newTuple);
}
tmp.push(newTuple);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment