本文整理了Java中org.apache.phoenix.util.QueryUtil.constructGenericUpsertStatement
方法的一些代码示例,展示了QueryUtil.constructGenericUpsertStatement
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。QueryUtil.constructGenericUpsertStatement
方法的具体详情如下:
包路径:org.apache.phoenix.util.QueryUtil
类名称:QueryUtil
方法名:constructGenericUpsertStatement
[英]Generate a generic upsert statement based on a number of columns. The created upsert statement will not include any named columns, but will include parameter markers for the given number of columns. The number of columns must be greater than zero.
[中]基于多个列生成通用upsert语句。创建的upsert语句将不包括任何命名列,但将包括给定列数的参数标记。列数必须大于零。
代码示例来源:origin: apache/phoenix
public static String getUpsertStatement(final Configuration configuration) throws SQLException {
Preconditions.checkNotNull(configuration);
String upsertStmt = configuration.get(UPSERT_STATEMENT);
if(isNotEmpty(upsertStmt)) {
return upsertStmt;
}
final String tableName = getOutputTableName(configuration);
Preconditions.checkNotNull(tableName);
List<String> upsertColumnNames = PhoenixConfigurationUtil.getUpsertColumnNames(configuration);
final List<ColumnInfo> columnMetadataList = getUpsertColumnMetadataList(configuration);
if (!upsertColumnNames.isEmpty()) {
// Generating UPSERT statement without column name information.
upsertStmt = QueryUtil.constructUpsertStatement(tableName, columnMetadataList);
LOG.info("Phoenix Custom Upsert Statement: "+ upsertStmt);
} else {
// Generating UPSERT statement without column name information.
upsertStmt = QueryUtil.constructGenericUpsertStatement(tableName, columnMetadataList.size());
LOG.info("Phoenix Generic Upsert Statement: " + upsertStmt);
}
configuration.set(UPSERT_STATEMENT, upsertStmt);
return upsertStmt;
}
代码示例来源:origin: apache/phoenix
@Test(expected=IllegalArgumentException.class)
public void testConstructGenericUpsertStatement_NoColumns() {
QueryUtil.constructGenericUpsertStatement("MYTAB", 0);
}
代码示例来源:origin: apache/phoenix
@Test
public void testConstructGenericUpsertStatement() {
assertEquals(
"UPSERT INTO MYTAB VALUES (?, ?)",
QueryUtil.constructGenericUpsertStatement("MYTAB", 2));
}
代码示例来源:origin: com.aliyun.phoenix/ali-phoenix-core
public static String getUpsertStatement(final Configuration configuration) throws SQLException {
Preconditions.checkNotNull(configuration);
String upsertStmt = configuration.get(UPSERT_STATEMENT);
if(isNotEmpty(upsertStmt)) {
return upsertStmt;
}
final String tableName = getOutputTableName(configuration);
Preconditions.checkNotNull(tableName);
List<String> upsertColumnNames = PhoenixConfigurationUtil.getUpsertColumnNames(configuration);
final List<ColumnInfo> columnMetadataList = getUpsertColumnMetadataList(configuration);
if (!upsertColumnNames.isEmpty()) {
// Generating UPSERT statement without column name information.
upsertStmt = QueryUtil.constructUpsertStatement(tableName, columnMetadataList);
LOG.info("Phoenix Custom Upsert Statement: "+ upsertStmt);
} else {
// Generating UPSERT statement without column name information.
upsertStmt = QueryUtil.constructGenericUpsertStatement(tableName, columnMetadataList.size());
LOG.info("Phoenix Generic Upsert Statement: " + upsertStmt);
}
configuration.set(UPSERT_STATEMENT, upsertStmt);
return upsertStmt;
}
代码示例来源:origin: org.apache.phoenix/phoenix-core
public static String getUpsertStatement(final Configuration configuration) throws SQLException {
Preconditions.checkNotNull(configuration);
String upsertStmt = configuration.get(UPSERT_STATEMENT);
if(isNotEmpty(upsertStmt)) {
return upsertStmt;
}
final String tableName = getOutputTableName(configuration);
Preconditions.checkNotNull(tableName);
List<String> upsertColumnNames = PhoenixConfigurationUtil.getUpsertColumnNames(configuration);
final List<ColumnInfo> columnMetadataList = getUpsertColumnMetadataList(configuration);
if (!upsertColumnNames.isEmpty()) {
// Generating UPSERT statement without column name information.
upsertStmt = QueryUtil.constructUpsertStatement(tableName, columnMetadataList);
LOG.info("Phoenix Custom Upsert Statement: "+ upsertStmt);
} else {
// Generating UPSERT statement without column name information.
upsertStmt = QueryUtil.constructGenericUpsertStatement(tableName, columnMetadataList.size());
LOG.info("Phoenix Generic Upsert Statement: " + upsertStmt);
}
configuration.set(UPSERT_STATEMENT, upsertStmt);
return upsertStmt;
}
内容来源于网络,如有侵权,请联系作者删除!