Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
import org.apache.phoenix.util.EnvironmentEdgeManager;
import org.apache.phoenix.util.PhoenixRuntime;
import org.apache.phoenix.util.ScanUtil;
import org.apache.phoenix.util.SchemaUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -92,8 +93,9 @@ private class TransformingDataTableQueryPlanBuilder implements QueryPlanBuilder
public QueryPlan getQueryPlan(PhoenixConnection phoenixConnection, String oldTableFullName,
String newTableFullName) throws SQLException {
PTable newTable = phoenixConnection.getTableNoCache(newTableFullName);
String quotedOldTableName = getQuotedTableNameForSQL(oldTableFullName);
ServerBuildTransformingTableCompiler compiler =
new ServerBuildTransformingTableCompiler(phoenixConnection, oldTableFullName);
new ServerBuildTransformingTableCompiler(phoenixConnection, quotedOldTableName);
MutationPlan plan = compiler.compile(newTable);
return plan.getQueryPlan();
}
Expand All @@ -104,8 +106,9 @@ private class DataTableQueryPlanBuilder implements QueryPlanBuilder {
public QueryPlan getQueryPlan(PhoenixConnection phoenixConnection, String dataTableFullName,
String indexTableFullName) throws SQLException {
PTable indexTable = phoenixConnection.getTableNoCache(indexTableFullName);
String quotedDataTableName = getQuotedTableNameForSQL(dataTableFullName);
ServerBuildIndexCompiler compiler =
new ServerBuildIndexCompiler(phoenixConnection, dataTableFullName);
new ServerBuildIndexCompiler(phoenixConnection, quotedDataTableName);
MutationPlan plan = compiler.compile(indexTable);
return plan.getQueryPlan();
}
Expand All @@ -117,7 +120,8 @@ public QueryPlan getQueryPlan(PhoenixConnection phoenixConnection, String dataTa
String indexTableFullName) throws SQLException {
QueryPlan plan;
try (final PhoenixStatement statement = new PhoenixStatement(phoenixConnection)) {
String query = "SELECT count(*) FROM " + indexTableFullName;
String quotedIndexName = getQuotedTableNameForSQL(indexTableFullName);
String query = "SELECT count(*) FROM " + quotedIndexName;
plan = statement.compileQuery(query);
TableRef tableRef = plan.getTableRef();
Scan scan = plan.getContext().getScan();
Expand All @@ -139,6 +143,12 @@ public QueryPlan getQueryPlan(PhoenixConnection phoenixConnection, String dataTa

private QueryPlanBuilder queryPlanBuilder;

private String getQuotedTableNameForSQL(String normalizedFullTableName) {
String schemaName = SchemaUtil.getSchemaNameFromFullName(normalizedFullTableName);
String tableName = SchemaUtil.getTableNameFromFullName(normalizedFullTableName);
return SchemaUtil.getFullTableNameWithQuotes(schemaName, tableName);
}

@Override
protected QueryPlan getQueryPlan(final JobContext context, final Configuration configuration)
throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ private Job configureJobForServerBuildIndex() throws Exception {
configuration.setBooleanIfUnset(
PhoenixConfigurationUtil.MAPREDUCE_RANDOMIZE_MAPPER_EXECUTION_ORDER, true);

PhoenixConfigurationUtil.setIndexToolDataTableName(configuration, dataTableWithSchema);
PhoenixConfigurationUtil.setIndexToolDataTableName(configuration, qDataTable);
PhoenixConfigurationUtil.setIndexToolIndexTableName(configuration, qIndexTable);
PhoenixConfigurationUtil.setIndexToolSourceTable(configuration, sourceTable);
if (startTime != null) {
Expand Down