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 |
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<String> |
createInsertValuesStmt(String tblColumns,
List<String> rows)
Genereates "Insert into T(a,b,c) values(1,2,'f'),(3,4,'c')" for appropriate DB
|
DatabaseProduct |
getDbProduct() |
public SQLGenerator(DatabaseProduct dbProduct, org.apache.hadoop.conf.Configuration conf)
public 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.MetaException
public 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.
MetaException
public DatabaseProduct getDbProduct()
Copyright © 2022 The Apache Software Foundation. All rights reserved.