public final class SQLGenerator extends Object
| Constructor and Description |
|---|
SQLGenerator(DatabaseProduct dbProduct,
org.apache.hadoop.conf.Configuration conf) |
| Modifier and Type | Method and Description |
|---|---|
String |
addEscapeCharacters(String s) |
String |
addForUpdateClause(String selectStatement)
Given a
selectStatement, decorated it with FOR UPDATE or semantically equivalent
construct. |
String |
addLimitClause(int numRows,
String noSelectsqlQuery)
Suppose you have a query "select a,b from T" and you want to limit the result set
to the first 5 rows.
|
List<PreparedStatement> |
createInsertValuesPreparedStmt(Connection dbConn,
String tblColumns,
List<String> rows,
List<List<String>> paramsList)
Generates "Insert into T(a,b,c) values(1,2,'f'),(3,4,'c')" for appropriate DB
|
List<String> |
createInsertValuesStmt(String tblColumns,
List<String> rows)
Generates "Insert into T(a,b,c) values(1,2,'f'),(3,4,'c')" for appropriate DB.
|
String |
createTxnLockStatement(boolean shared)
Creates a lock statement for open/commit transaction based on the dbProduct in shared read / exclusive mode.
|
List<String> |
getCreateQueriesForMetastoreSummary()
Create or replace a view that stores all the info regarding metastore summary.
|
DatabaseProduct |
getDbProduct() |
String |
getSelectQueryForMetastoreSummary() |
String |
lockTable(String txnLockTable,
boolean shared)
Returns the SQL query to lock the given table name in either shared/exclusive mode
|
PreparedStatement |
prepareStmtWithParameters(Connection dbConn,
String sql,
List<String> parameters)
Make PreparedStatement object with list of String type parameters to be set.
|
public SQLGenerator(DatabaseProduct dbProduct, org.apache.hadoop.conf.Configuration conf)
public List<PreparedStatement> createInsertValuesPreparedStmt(Connection dbConn, String tblColumns, List<String> rows, List<List<String>> paramsList) throws SQLException
tblColumns - e.g. "T(a,b,c)"rows - e.g. list of Strings like 3,4,'d'paramsList - List of parameters which in turn is list of Strings to be set in PreparedStatement objectSQLExceptionpublic List<String> createInsertValuesStmt(String tblColumns, List<String> rows)
tblColumns - e.g. "T(a,b,c)"rows - e.g. list of Strings like 3,4,'d'public String addForUpdateClause(String selectStatement) throws MetaException
selectStatement, decorated it with FOR UPDATE or semantically equivalent
construct. If the DB doesn't support, return original select.MetaExceptionpublic String addLimitClause(int numRows, String noSelectsqlQuery) throws MetaException
noSelectsqlQuery to be "a,b from T" and this method will return the
appropriately modified row limiting query.
Note that if noSelectsqlQuery contains a join, you must make sure that
all columns are unique for Oracle.
MetaExceptionpublic String lockTable(String txnLockTable, boolean shared) throws MetaException
txnLockTable - shared - MetaExceptionpublic PreparedStatement prepareStmtWithParameters(Connection dbConn, String sql, List<String> parameters) throws SQLException
dbConn - - Connection objectsql - - SQL statement with "?" for input parameters.parameters - - List of String type parameters to be set in PreparedStatement objectSQLExceptionpublic List<String> getCreateQueriesForMetastoreSummary()
public String getSelectQueryForMetastoreSummary()
public DatabaseProduct getDbProduct()
public String createTxnLockStatement(boolean shared) throws MetaException
shared - shared or exclusive lockMetaException - if the dbProduct is unknownCopyright © 2024 The Apache Software Foundation. All rights reserved.