Skip to content

Commit

Permalink
storage: ALTER VIEW DROP COLUMN not supported on phoenix 5.1.x #TASK-…
Browse files Browse the repository at this point in the history
…5663
  • Loading branch information
j-coll committed Feb 20, 2024
1 parent 2011121 commit 9bba168
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ public interface PhoenixCompatApi {

<T extends DBWritable> PhoenixRecordReader<T> newPhoenixRecordReader(
Class<T> inputClass, Configuration configuration, QueryPlan queryPlan);

boolean isDropColumnFromViewSupported();
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,9 @@ public <T extends DBWritable> PhoenixRecordReader<T> newPhoenixRecordReader(Clas
throw new IllegalStateException(e);
}
}

@Override
public boolean isDropColumnFromViewSupported() {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,8 @@ public <T extends DBWritable> PhoenixRecordReader<T> newPhoenixRecordReader(Clas
return new PhoenixRecordReader<>(inputClass, configuration, queryPlan);
}

@Override
public boolean isDropColumnFromViewSupported() {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,11 @@ public <T extends DBWritable> PhoenixRecordReader<T> newPhoenixRecordReader(Clas
}
}

@Override
public boolean isDropColumnFromViewSupported() {
// Phoenix 5.1.x does not support drop column from view.
// Might be related with https://issues.apache.org/jira/browse/PHOENIX-6025
return false;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import org.opencb.opencga.core.common.BatchUtils;
import org.opencb.opencga.core.common.ExceptionUtils;
import org.opencb.opencga.core.common.TimeUtils;
import org.opencb.opencga.storage.hadoop.HBaseCompat;
import org.opencb.opencga.storage.hadoop.utils.HBaseManager;
import org.opencb.opencga.storage.hadoop.variant.GenomeHelper;
import org.slf4j.Logger;
Expand Down Expand Up @@ -255,6 +256,12 @@ public String buildAlterDropColumns(String tableName, Collection<CharSequence> c
public void dropColumns(Connection con, String tableName, Collection<CharSequence> columns, PTableType tableType)
throws SQLException {

if (!HBaseCompat.getInstance().getPhoenixCompat().isDropColumnFromViewSupported()) {
logger.info("Dropping columns is not supported for Phoenix version {}.{} . Skipping drop columns.",
PhoenixDriver.INSTANCE.getMajorVersion(), PhoenixDriver.INSTANCE.getMinorVersion());
return;
}

Set<String> existingColumns = getColumns(con, tableName, tableType)
.stream()
.map(Column::column)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,18 +352,19 @@ public void testDuplicatedVariantsAccepted(String... files) throws Exception {
for (Boolean nativeQuery : Arrays.asList(true, false)) {
String name = fileMetadata.getName();
Query query = new Query(VariantQueryParam.FILE.key(), name);
QueryOptions options = new QueryOptions(NATIVE, nativeQuery);
System.out.println("-----------------------");
System.out.println("FILE-QUERY = " + query.toJson());
for (Variant variant : variantStorageEngine.get(query, new QueryOptions(NATIVE, nativeQuery)).getResults()) {
System.out.println("FILE-QUERY = " + query.toJson() + " " + options.toJson());
for (Variant variant : variantStorageEngine.get(query, new QueryOptions(options)).getResults()) {
StudyEntry studyEntry = variant.getStudies().get(0);
assertEquals(0, studyEntry.getIssues().size());
assertEquals(name, studyEntry.getFiles().get(0).getFileId());
}
for (Integer sample : fileMetadata.getSamples()) {
String sampleName = metadataManager.getSampleName(studyId, sample);
query = new Query(VariantQueryParam.FILE.key(), name).append(VariantQueryParam.SAMPLE.key(), sampleName);
System.out.println("SAMPLE-QUERY = " + query.toJson());
for (Variant variant : variantStorageEngine.get(query, new QueryOptions(NATIVE, nativeQuery)).getResults()) {
System.out.println("SAMPLE-QUERY = " + query.toJson() + " " + options.toJson());
for (Variant variant : variantStorageEngine.get(query, new QueryOptions(options)).getResults()) {
StudyEntry studyEntry = variant.getStudies().get(0);
assertEquals(0, studyEntry.getIssues().size());
assertEquals(name, studyEntry.getFiles().get(0).getFileId());
Expand Down

0 comments on commit 9bba168

Please sign in to comment.