stoty commented on a change in pull request #1265:
URL: https://github.com/apache/phoenix/pull/1265#discussion_r670648449



##########
File path: 
phoenix-core/src/main/java/org/apache/phoenix/mapreduce/AbstractBulkLoadTool.java
##########
@@ -226,6 +228,14 @@ private int loadData(Configuration conf, CommandLine 
cmdLine) throws Exception {
         configureOptions(cmdLine, importColumns, conf);
         String sName = SchemaUtil.normalizeIdentifier(schemaName);
         String tName = SchemaUtil.normalizeIdentifier(tableName);
+
+        // There must be a better solution for this

Review comment:
       nit:
   I don't think there really is.
   We could query the table via HBase API directly, but that wouldn't really 
help.

##########
File path: 
phoenix-core/src/main/java/org/apache/phoenix/mapreduce/AbstractBulkLoadTool.java
##########
@@ -244,14 +254,26 @@ private int loadData(Configuration conf, CommandLine 
cmdLine) throws Exception {
         PTable table = PhoenixRuntime.getTable(conn, qualifiedTableName);
         tablesToBeLoaded.add(new TargetTableRef(qualifiedTableName, 
table.getPhysicalName().getString()));
         boolean hasLocalIndexes = false;
+        boolean hasGlobalIndexes = false;
         for(PTable index: table.getIndexes()) {
             if (index.getIndexType() == IndexType.LOCAL) {
                 hasLocalIndexes =
                         qualifiedIndexTableName == null ? true : 
index.getTableName().getString()
                                 .equals(qualifiedIndexTableName);
-                if (hasLocalIndexes) break;
+                if (hasLocalIndexes && hasGlobalIndexes) break;
+            }
+            if (index.getIndexType() == IndexType.GLOBAL) {
+                hasGlobalIndexes = true;
+                if (hasLocalIndexes && hasGlobalIndexes) break;
             }
         }
+
+        if(hasGlobalIndexes && tableNotEmpty && 
!cmdLine.hasOption(ENABLE_CORRUPT_INDEXES.getOpt())){
+            throw new IllegalStateException("Bulk Loader error: Bulk loading 
is disabled for" +

Review comment:
       A bit more context may help:
   
   Bulk Loading error: Bulk loading is disabled for non empty tables with 
global indexes, because it will corrupt the global index table in most cases.
   Use the --corruptindexes option to override this check.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to