Repository: tajo Updated Branches: refs/heads/master fd6a95180 -> 903151ead
http://git-wip-us.apache.org/repos/asf/tajo/blob/903151ea/tajo-storage/tajo-storage-common/src/main/java/org/apache/tajo/storage/Tablespace.java ---------------------------------------------------------------------- diff --git a/tajo-storage/tajo-storage-common/src/main/java/org/apache/tajo/storage/Tablespace.java b/tajo-storage/tajo-storage-common/src/main/java/org/apache/tajo/storage/Tablespace.java index 968601c..0094310 100644 --- a/tajo-storage/tajo-storage-common/src/main/java/org/apache/tajo/storage/Tablespace.java +++ b/tajo-storage/tajo-storage-common/src/main/java/org/apache/tajo/storage/Tablespace.java @@ -128,7 +128,7 @@ public abstract class Tablespace { * @throws java.io.IOException */ public abstract List<Fragment> getSplits(String fragmentId, TableDesc tableDesc, - ScanNode scanNode) throws IOException; + ScanNode scanNode) throws IOException, TajoException; /** * It returns the splits that will serve as input for the non-forward query scanner such as 'select * from table1'. @@ -200,7 +200,7 @@ public abstract class Tablespace { * @return The list of input fragments. * @throws java.io.IOException */ - public List<Fragment> getSplits(String fragmentId, TableDesc tableDesc) throws IOException { + public List<Fragment> getSplits(String fragmentId, TableDesc tableDesc) throws IOException, TajoException { return getSplits(fragmentId, tableDesc, null); } @@ -345,7 +345,7 @@ public abstract class Tablespace { * @param outSchema The output schema of select query for inserting. * @throws java.io.IOException */ - public abstract void verifySchemaToWrite(TableDesc tableDesc, Schema outSchema) throws IOException; + public abstract void verifySchemaToWrite(TableDesc tableDesc, Schema outSchema) throws TajoException; /** * Rewrite the logical plan. It is assumed that the final plan will be given in this method. @@ -366,7 +366,7 @@ public abstract class Tablespace { * @param ifNotExists Creates the table only when the table does not exist. * @throws java.io.IOException */ - public abstract void createTable(TableDesc tableDesc, boolean ifNotExists) throws IOException; + public abstract void createTable(TableDesc tableDesc, boolean ifNotExists) throws TajoException, IOException; /** * This method is called after executing "DROP TABLE" statement with the 'PURGE' option @@ -375,7 +375,7 @@ public abstract class Tablespace { * @param tableDesc * @throws java.io.IOException */ - public abstract void purgeTable(TableDesc tableDesc) throws IOException; + public abstract void purgeTable(TableDesc tableDesc) throws IOException, TajoException; /** * This method is called before executing 'INSERT' or 'CREATE TABLE as SELECT'. @@ -386,7 +386,7 @@ public abstract class Tablespace { * @param node The child node of the root node. * @throws java.io.IOException */ - public abstract void prepareTable(LogicalNode node) throws IOException; + public abstract void prepareTable(LogicalNode node) throws IOException, TajoException; /** * Finalizes result data. Tajo stores result data in the staging directory. @@ -406,7 +406,7 @@ public abstract class Tablespace { LogicalPlan plan, Schema schema, TableDesc tableDesc) throws IOException; - public abstract void rollbackTable(LogicalNode node) throws IOException; + public abstract void rollbackTable(LogicalNode node) throws IOException, TajoException; @Override public boolean equals(Object obj) { http://git-wip-us.apache.org/repos/asf/tajo/blob/903151ea/tajo-storage/tajo-storage-hbase/src/main/java/org/apache/tajo/storage/hbase/AbstractHBaseAppender.java ---------------------------------------------------------------------- diff --git a/tajo-storage/tajo-storage-hbase/src/main/java/org/apache/tajo/storage/hbase/AbstractHBaseAppender.java b/tajo-storage/tajo-storage-hbase/src/main/java/org/apache/tajo/storage/hbase/AbstractHBaseAppender.java index 0fc2922..af78d13 100644 --- a/tajo-storage/tajo-storage-hbase/src/main/java/org/apache/tajo/storage/hbase/AbstractHBaseAppender.java +++ b/tajo-storage/tajo-storage-hbase/src/main/java/org/apache/tajo/storage/hbase/AbstractHBaseAppender.java @@ -26,6 +26,10 @@ import org.apache.tajo.catalog.Schema; import org.apache.tajo.catalog.TableMeta; import org.apache.tajo.catalog.statistics.TableStats; import org.apache.tajo.datum.Datum; +import org.apache.tajo.exception.InvalidTablePropertyException; +import org.apache.tajo.exception.MissingTablePropertyException; +import org.apache.tajo.exception.TajoException; +import org.apache.tajo.exception.TajoInternalError; import org.apache.tajo.storage.Appender; import org.apache.tajo.storage.TableStatistics; import org.apache.tajo.storage.Tuple; @@ -89,7 +93,11 @@ public abstract class AbstractHBaseAppender implements Appender { if (enabledStats) { stats = new TableStatistics(this.schema); } - columnMapping = new ColumnMapping(schema, meta.getOptions()); + try { + columnMapping = new ColumnMapping(schema, meta.getOptions()); + } catch (TajoException e) { + throw new TajoInternalError(e); + } mappingColumnFamilies = columnMapping.getMappingColumns(); http://git-wip-us.apache.org/repos/asf/tajo/blob/903151ea/tajo-storage/tajo-storage-hbase/src/main/java/org/apache/tajo/storage/hbase/ColumnMapping.java ---------------------------------------------------------------------- diff --git a/tajo-storage/tajo-storage-hbase/src/main/java/org/apache/tajo/storage/hbase/ColumnMapping.java b/tajo-storage/tajo-storage-hbase/src/main/java/org/apache/tajo/storage/hbase/ColumnMapping.java index 0314e8e..7df7e9c 100644 --- a/tajo-storage/tajo-storage-hbase/src/main/java/org/apache/tajo/storage/hbase/ColumnMapping.java +++ b/tajo-storage/tajo-storage-hbase/src/main/java/org/apache/tajo/storage/hbase/ColumnMapping.java @@ -20,6 +20,9 @@ package org.apache.tajo.storage.hbase; import org.apache.hadoop.hbase.util.Bytes; import org.apache.tajo.catalog.Schema; +import org.apache.tajo.exception.InvalidTablePropertyException; +import org.apache.tajo.exception.MissingTablePropertyException; +import org.apache.tajo.exception.TajoException; import org.apache.tajo.util.BytesUtils; import org.apache.tajo.util.KeyValueSet; @@ -45,13 +48,14 @@ public class ColumnMapping { private int numRowKeys; - public ColumnMapping(Schema schema, KeyValueSet tableProperty) throws IOException{ + public ColumnMapping(Schema schema, KeyValueSet tableProperty) + throws MissingTablePropertyException, InvalidTablePropertyException { this.schema = schema; this.tableProperty = tableProperty; init(); } - public void init() throws IOException { + public void init() throws MissingTablePropertyException, InvalidTablePropertyException { hbaseTableName = tableProperty.get(HBaseStorageConstants.META_TABLE_KEY); String delim = tableProperty.get(HBaseStorageConstants.META_ROWKEY_DELIMITER, "").trim(); if (delim.length() > 0) { @@ -71,13 +75,14 @@ public class ColumnMapping { String columnMapping = tableProperty.get(HBaseStorageConstants.META_COLUMNS_KEY, ""); if (columnMapping == null || columnMapping.isEmpty()) { - throw new IOException("'columns' property is required."); + throw new MissingTablePropertyException(HBaseStorageConstants.META_COLUMNS_KEY, hbaseTableName); } String[] columnMappingTokens = columnMapping.split(","); if (columnMappingTokens.length != schema.getRootColumns().size()) { - throw new IOException("The number of mapped HBase columns is great than the number of Tajo table columns"); + throw new InvalidTablePropertyException( + "mapping column pairs must be more than number of columns in the schema", hbaseTableName); } int index = 0; @@ -89,8 +94,9 @@ public class ColumnMapping { if (mappingTokens.length == 3) { if (mappingTokens[0].length == 0) { // cfname - throw new IOException(eachToken + " 'column' attribute should be '<cfname>:key:' or '<cfname>:key:#b' " + - "or '<cfname>:value:' or '<cfname>:value:#b'"); + throw new InvalidTablePropertyException(eachToken + + " 'column' attribute should be '<cfname>:key:' or '<cfname>:key:#b' " + + "or '<cfname>:value:' or '<cfname>:value:#b'", hbaseTableName); } //<cfname>:key: or <cfname>:value: if (mappingTokens[2].length != 0) { @@ -98,8 +104,9 @@ public class ColumnMapping { if ("#b".equals(binaryOption)) { isBinaryColumns[index] = true; } else { - throw new IOException(eachToken + " 'column' attribute should be '<cfname>:key:' or '<cfname>:key:#b' " + - "or '<cfname>:value:' or '<cfname>:value:#b'"); + throw new InvalidTablePropertyException(eachToken + + " 'column' attribute should be '<cfname>:key:' or '<cfname>:key:#b' " + + "or '<cfname>:value:' or '<cfname>:value:#b'", hbaseTableName); } } mappingColumns[index][0] = mappingTokens[0]; @@ -109,7 +116,9 @@ public class ColumnMapping { } else if (HBaseStorageConstants.VALUE_COLUMN_MAPPING.equalsIgnoreCase(keyOrValue)) { isColumnValues[index] = true; } else { - throw new IOException(eachToken + " 'column' attribute should be '<cfname>:key:' or '<cfname>:value:'"); + throw new InvalidTablePropertyException(eachToken + + " 'column' attribute should be '<cfname>:key:' or '<cfname>:value:'", + hbaseTableName); } } else if (mappingTokens.length == 2) { //<cfname>: or <cfname>:<qualifier> or :key @@ -122,7 +131,8 @@ public class ColumnMapping { isBinaryColumns[index] = rowKeyMapping.isBinary(); if (!cfName.isEmpty()) { if (rowKeyDelimiter == 0) { - throw new IOException("hbase.rowkey.delimiter is required."); + throw new InvalidTablePropertyException("hbase.rowkey.delimiter is required.", + hbaseTableName); } rowKeyFieldIndexes[index] = Integer.parseInt(cfName); } else { @@ -130,7 +140,9 @@ public class ColumnMapping { } } else { if (cfName.isEmpty()) { - throw new IOException(eachToken + " 'column' attribute should be '<cfname>:key:' or '<cfname>:value:'"); + throw new InvalidTablePropertyException(eachToken + + " 'column' attribute should be '<cfname>:key:' or '<cfname>:value:'", + hbaseTableName); } if (cfName != null) { mappingColumns[index][0] = Bytes.toBytes(cfName); @@ -149,7 +161,8 @@ public class ColumnMapping { } } } else { - throw new IOException(eachToken + " 'column' attribute '[cfname]:[qualfier]:'"); + throw new InvalidTablePropertyException(eachToken + " 'column' attribute '[cfname]:[qualfier]:'" + , hbaseTableName); } index++; http://git-wip-us.apache.org/repos/asf/tajo/blob/903151ea/tajo-storage/tajo-storage-hbase/src/main/java/org/apache/tajo/storage/hbase/HBaseBinarySerializerDeserializer.java ---------------------------------------------------------------------- diff --git a/tajo-storage/tajo-storage-hbase/src/main/java/org/apache/tajo/storage/hbase/HBaseBinarySerializerDeserializer.java b/tajo-storage/tajo-storage-hbase/src/main/java/org/apache/tajo/storage/hbase/HBaseBinarySerializerDeserializer.java index 40c4aea..ff6fa59 100644 --- a/tajo-storage/tajo-storage-hbase/src/main/java/org/apache/tajo/storage/hbase/HBaseBinarySerializerDeserializer.java +++ b/tajo-storage/tajo-storage-hbase/src/main/java/org/apache/tajo/storage/hbase/HBaseBinarySerializerDeserializer.java @@ -66,7 +66,7 @@ public class HBaseBinarySerializerDeserializer { return datum; } - public static byte[] serialize(Column col, Datum datum) throws IOException { + public static byte[] serialize(Column col, Datum datum) { if (datum == null || datum instanceof NullDatum) { return null; } http://git-wip-us.apache.org/repos/asf/tajo/blob/903151ea/tajo-storage/tajo-storage-hbase/src/main/java/org/apache/tajo/storage/hbase/HBaseScanner.java ---------------------------------------------------------------------- diff --git a/tajo-storage/tajo-storage-hbase/src/main/java/org/apache/tajo/storage/hbase/HBaseScanner.java b/tajo-storage/tajo-storage-hbase/src/main/java/org/apache/tajo/storage/hbase/HBaseScanner.java index 1626526..beae592 100644 --- a/tajo-storage/tajo-storage-hbase/src/main/java/org/apache/tajo/storage/hbase/HBaseScanner.java +++ b/tajo-storage/tajo-storage-hbase/src/main/java/org/apache/tajo/storage/hbase/HBaseScanner.java @@ -36,7 +36,7 @@ import org.apache.tajo.conf.TajoConf; import org.apache.tajo.datum.Datum; import org.apache.tajo.datum.NullDatum; import org.apache.tajo.datum.TextDatum; -import org.apache.tajo.exception.UnsupportedException; +import org.apache.tajo.exception.*; import org.apache.tajo.plan.expr.EvalNode; import org.apache.tajo.storage.*; import org.apache.tajo.storage.fragment.Fragment; @@ -123,7 +123,11 @@ public class HBaseScanner implements Scanner { outTuple = new VTuple(targets.length); - columnMapping = new ColumnMapping(schema, meta.getOptions()); + try { + columnMapping = new ColumnMapping(schema, meta.getOptions()); + } catch (TajoException e) { + new TajoInternalError(e); + } targetIndexes = new int[targets.length]; int index = 0; for (Column eachTargetColumn: targets) { http://git-wip-us.apache.org/repos/asf/tajo/blob/903151ea/tajo-storage/tajo-storage-hbase/src/main/java/org/apache/tajo/storage/hbase/HBaseTablespace.java ---------------------------------------------------------------------- diff --git a/tajo-storage/tajo-storage-hbase/src/main/java/org/apache/tajo/storage/hbase/HBaseTablespace.java b/tajo-storage/tajo-storage-hbase/src/main/java/org/apache/tajo/storage/hbase/HBaseTablespace.java index 35c974b..f613b88 100644 --- a/tajo-storage/tajo-storage-hbase/src/main/java/org/apache/tajo/storage/hbase/HBaseTablespace.java +++ b/tajo-storage/tajo-storage-hbase/src/main/java/org/apache/tajo/storage/hbase/HBaseTablespace.java @@ -42,6 +42,9 @@ import org.apache.tajo.common.TajoDataTypes.Type; import org.apache.tajo.conf.TajoConf; import org.apache.tajo.datum.Datum; import org.apache.tajo.datum.TextDatum; +import org.apache.tajo.exception.DataTypeMismatchException; +import org.apache.tajo.exception.InvalidTablePropertyException; +import org.apache.tajo.exception.MissingTablePropertyException; import org.apache.tajo.exception.TajoException; import org.apache.tajo.plan.LogicalPlan; import org.apache.tajo.plan.expr.*; @@ -50,6 +53,7 @@ import org.apache.tajo.plan.logical.LogicalNode; import org.apache.tajo.plan.logical.NodeType; import org.apache.tajo.plan.logical.ScanNode; import org.apache.tajo.plan.rewrite.LogicalPlanRewriteRuleContext; +import org.apache.tajo.plan.verifier.SyntaxErrorUtil; import org.apache.tajo.storage.*; import org.apache.tajo.storage.fragment.Fragment; import org.apache.tajo.util.*; @@ -120,7 +124,7 @@ public class HBaseTablespace extends Tablespace { } @Override - public void createTable(TableDesc tableDesc, boolean ifNotExists) throws IOException { + public void createTable(TableDesc tableDesc, boolean ifNotExists) throws TajoException, IOException { createTable(tableDesc.getUri(), tableDesc.getMeta(), tableDesc.getSchema(), tableDesc.isExternal(), ifNotExists); TableStats stats = new TableStats(); stats.setNumRows(TajoConstants.UNKNOWN_ROW_NUMBER); @@ -128,17 +132,17 @@ public class HBaseTablespace extends Tablespace { } private void createTable(URI uri, TableMeta tableMeta, Schema schema, - boolean isExternal, boolean ifNotExists) throws IOException { + boolean isExternal, boolean ifNotExists) throws TajoException, IOException { String hbaseTableName = tableMeta.getOption(HBaseStorageConstants.META_TABLE_KEY, ""); if (hbaseTableName == null || hbaseTableName.trim().isEmpty()) { - throw new IOException("HBase mapped table is required a '" + - HBaseStorageConstants.META_TABLE_KEY + "' attribute."); + throw new MissingTablePropertyException(HBaseStorageConstants.META_TABLE_KEY, "hbase"); } TableName hTableName = TableName.valueOf(hbaseTableName); String mappedColumns = tableMeta.getOption(HBaseStorageConstants.META_COLUMNS_KEY, ""); if (mappedColumns != null && mappedColumns.split(",").length > schema.size()) { - throw new IOException("Columns property has more entry than Tajo table columns"); + throw new InvalidTablePropertyException(HBaseStorageConstants.META_COLUMNS_KEY, + "mapping column pairs must be more than number of columns in the schema"); } ColumnMapping columnMapping = new ColumnMapping(schema, tableMeta.getOptions()); @@ -152,17 +156,17 @@ public class HBaseTablespace extends Tablespace { if (numRowKeys > 1) { for (int i = 0; i < isRowKeyMappings.length; i++) { if (isRowKeyMappings[i] && schema.getColumn(i).getDataType().getType() != Type.TEXT) { - throw new IOException("Key field type should be TEXT type."); + throw SyntaxErrorUtil.makeSyntaxError("Key field type should be TEXT type."); } } } for (int i = 0; i < isRowKeyMappings.length; i++) { if (columnMapping.getIsColumnKeys()[i] && schema.getColumn(i).getDataType().getType() != Type.TEXT) { - throw new IOException("Column key field('<cfname>:key:') type should be TEXT type."); + throw SyntaxErrorUtil.makeSyntaxError("Column key field('<cfname>:key:') type should be TEXT type."); } if (columnMapping.getIsColumnValues()[i] && schema.getColumn(i).getDataType().getType() != Type.TEXT) { - throw new IOException("Column value field(('<cfname>:value:') type should be TEXT type."); + throw SyntaxErrorUtil.makeSyntaxError("Column value field(('<cfname>:value:') type should be TEXT type."); } } @@ -172,8 +176,7 @@ public class HBaseTablespace extends Tablespace { if (isExternal) { // If tajo table is external table, only check validation. if (mappedColumns == null || mappedColumns.isEmpty()) { - throw new IOException("HBase mapped table is required a '" + - HBaseStorageConstants.META_COLUMNS_KEY + "' attribute."); + throw new MissingTablePropertyException(HBaseStorageConstants.META_COLUMNS_KEY, hbaseTableName); } if (!hAdmin.tableExists(hTableName)) { throw new IOException("HBase table [" + hbaseTableName + "] not exists. " + @@ -187,8 +190,7 @@ public class HBaseTablespace extends Tablespace { Collection<String> mappingColumnFamilies =columnMapping.getColumnFamilyNames(); if (mappingColumnFamilies.isEmpty()) { - throw new IOException("HBase mapped table is required a '" + - HBaseStorageConstants.META_COLUMNS_KEY + "' attribute."); + throw new MissingTablePropertyException(HBaseStorageConstants.META_COLUMNS_KEY, hbaseTableName); } for (String eachMappingColumnFamily : mappingColumnFamilies) { @@ -207,7 +209,7 @@ public class HBaseTablespace extends Tablespace { // Creating hbase table HTableDescriptor hTableDescriptor = parseHTableDescriptor(tableMeta, schema); - byte[][] splitKeys = getSplitKeys(conf, schema, tableMeta); + byte[][] splitKeys = getSplitKeys(conf, hbaseTableName, schema, tableMeta); if (splitKeys == null) { hAdmin.createTable(hTableDescriptor); } else { @@ -228,7 +230,9 @@ public class HBaseTablespace extends Tablespace { * @return * @throws java.io.IOException */ - private byte[][] getSplitKeys(TajoConf conf, Schema schema, TableMeta meta) throws IOException { + private byte[][] getSplitKeys(TajoConf conf, String hbaseTableName, Schema schema, TableMeta meta) + throws MissingTablePropertyException, InvalidTablePropertyException, IOException { + String splitRowKeys = meta.getOption(HBaseStorageConstants.META_SPLIT_ROW_KEYS_KEY, ""); String splitRowKeysFile = meta.getOption(HBaseStorageConstants.META_SPLIT_ROW_KEYS_FILE_KEY, ""); @@ -255,8 +259,8 @@ public class HBaseTablespace extends Tablespace { } if (rowkeyBinary && numRowKeys > 1) { - throw new IOException("If rowkey is mapped to multi column and a rowkey is binary, " + - "Multiple region for creation is not support."); + throw new InvalidTablePropertyException("If rowkey is mapped to multi column and a rowkey is binary, " + + "Multiple region for creation is not support.", hbaseTableName); } if (splitRowKeys != null && !splitRowKeys.isEmpty()) { @@ -277,7 +281,8 @@ public class HBaseTablespace extends Tablespace { Path path = new Path(splitRowKeysFile); FileSystem fs = path.getFileSystem(conf); if (!fs.exists(path)) { - throw new IOException("hbase.split.rowkeys.file=" + path.toString() + " not exists."); + throw new MissingTablePropertyException("hbase.split.rowkeys.file=" + path.toString() + " not exists.", + hbaseTableName); } SortedSet<String> splitKeySet = new TreeSet<String>(); @@ -345,11 +350,12 @@ public class HBaseTablespace extends Tablespace { * @return * @throws java.io.IOException */ - public static HTableDescriptor parseHTableDescriptor(TableMeta tableMeta, Schema schema) throws IOException { + public static HTableDescriptor parseHTableDescriptor(TableMeta tableMeta, Schema schema) + throws MissingTablePropertyException, InvalidTablePropertyException { + String hbaseTableName = tableMeta.getOption(HBaseStorageConstants.META_TABLE_KEY, ""); if (hbaseTableName == null || hbaseTableName.trim().isEmpty()) { - throw new IOException("HBase mapped table is required a '" + - HBaseStorageConstants.META_TABLE_KEY + "' attribute."); + throw new MissingTablePropertyException(HBaseStorageConstants.META_TABLE_KEY, hbaseTableName); } TableName hTableName = TableName.valueOf(hbaseTableName); @@ -373,7 +379,7 @@ public class HBaseTablespace extends Tablespace { } @Override - public void purgeTable(TableDesc tableDesc) throws IOException { + public void purgeTable(TableDesc tableDesc) throws IOException, TajoException { HBaseAdmin hAdmin = new HBaseAdmin(hbaseConf); try { @@ -398,7 +404,9 @@ public class HBaseTablespace extends Tablespace { * @return * @throws java.io.IOException */ - private Column[] getIndexableColumns(TableDesc tableDesc) throws IOException { + private Column[] getIndexableColumns(TableDesc tableDesc) throws + MissingTablePropertyException, InvalidTablePropertyException { + ColumnMapping columnMapping = new ColumnMapping(tableDesc.getSchema(), tableDesc.getMeta().getOptions()); boolean[] isRowKeyMappings = columnMapping.getIsRowKeyMappings(); int[] rowKeyIndexes = columnMapping.getRowKeyFieldIndexes(); @@ -416,7 +424,9 @@ public class HBaseTablespace extends Tablespace { } @Override - public List<Fragment> getSplits(String fragmentId, TableDesc tableDesc, ScanNode scanNode) throws IOException { + public List<Fragment> getSplits(String fragmentId, TableDesc tableDesc, ScanNode scanNode) + throws IOException, TajoException { + ColumnMapping columnMapping = new ColumnMapping(tableDesc.getSchema(), tableDesc.getMeta().getOptions()); List<IndexPredication> indexPredications = getIndexPredications(columnMapping, tableDesc, scanNode); @@ -786,7 +796,9 @@ public class HBaseTablespace extends Tablespace { } public List<IndexPredication> getIndexPredications(ColumnMapping columnMapping, - TableDesc tableDesc, ScanNode scanNode) throws IOException { + TableDesc tableDesc, ScanNode scanNode) + throws IOException, MissingTablePropertyException, InvalidTablePropertyException { + List<IndexPredication> indexPredications = new ArrayList<IndexPredication>(); Column[] indexableColumns = getIndexableColumns(tableDesc); if (indexableColumns != null && indexableColumns.length == 1) { @@ -1112,7 +1124,7 @@ public class HBaseTablespace extends Tablespace { } } - public void prepareTable(LogicalNode node) throws IOException { + public void prepareTable(LogicalNode node) throws TajoException, IOException { if (node.getType() == NodeType.CREATE_TABLE) { CreateTableNode cNode = (CreateTableNode)node; if (!cNode.isExternal()) { @@ -1125,7 +1137,7 @@ public class HBaseTablespace extends Tablespace { } @Override - public void rollbackTable(LogicalNode node) throws IOException { + public void rollbackTable(LogicalNode node) throws IOException, TajoException { if (node.getType() == NodeType.CREATE_TABLE) { CreateTableNode cNode = (CreateTableNode)node; if (cNode.isExternal()) { @@ -1164,19 +1176,22 @@ public class HBaseTablespace extends Tablespace { } @Override - public void verifySchemaToWrite(TableDesc tableDesc, Schema outSchema) throws IOException { + public void verifySchemaToWrite(TableDesc tableDesc, Schema outSchema) throws TajoException { if (tableDesc != null) { Schema tableSchema = tableDesc.getSchema(); if (tableSchema.size() != outSchema.size()) { - throw new IOException("The number of table columns is different from SELECT columns"); + throw SyntaxErrorUtil.makeSyntaxError("Target columns and projected columns are mismatched to each other"); } for (int i = 0; i < tableSchema.size(); i++) { if (!tableSchema.getColumn(i).getDataType().equals(outSchema.getColumn(i).getDataType())) { - throw new IOException(outSchema.getColumn(i).getQualifiedName() + - "(" + outSchema.getColumn(i).getDataType().getType() + ")" + - " is different column type with " + tableSchema.getColumn(i).getSimpleName() + - "(" + tableSchema.getColumn(i).getDataType().getType() + ")"); + final Column tableColumn = tableSchema.getColumn(i); + final Column outColumn = outSchema.getColumn(i); + throw new DataTypeMismatchException( + tableColumn.getQualifiedName(), + tableColumn.getDataType().getType().name(), + outColumn.getQualifiedName(), + outColumn.getDataType().getType().name()); } } } http://git-wip-us.apache.org/repos/asf/tajo/blob/903151ea/tajo-storage/tajo-storage-hbase/src/main/java/org/apache/tajo/storage/hbase/HBaseTextSerializerDeserializer.java ---------------------------------------------------------------------- diff --git a/tajo-storage/tajo-storage-hbase/src/main/java/org/apache/tajo/storage/hbase/HBaseTextSerializerDeserializer.java b/tajo-storage/tajo-storage-hbase/src/main/java/org/apache/tajo/storage/hbase/HBaseTextSerializerDeserializer.java index ea5d0b0..c868cd1 100644 --- a/tajo-storage/tajo-storage-hbase/src/main/java/org/apache/tajo/storage/hbase/HBaseTextSerializerDeserializer.java +++ b/tajo-storage/tajo-storage-hbase/src/main/java/org/apache/tajo/storage/hbase/HBaseTextSerializerDeserializer.java @@ -62,7 +62,7 @@ public class HBaseTextSerializerDeserializer { return datum; } - public static byte[] serialize(Column col, Datum datum) throws IOException { + public static byte[] serialize(Column col, Datum datum) { if (datum == null || datum instanceof NullDatum) { return null; } http://git-wip-us.apache.org/repos/asf/tajo/blob/903151ea/tajo-storage/tajo-storage-hbase/src/main/java/org/apache/tajo/storage/hbase/SortedInsertRewriter.java ---------------------------------------------------------------------- diff --git a/tajo-storage/tajo-storage-hbase/src/main/java/org/apache/tajo/storage/hbase/SortedInsertRewriter.java b/tajo-storage/tajo-storage-hbase/src/main/java/org/apache/tajo/storage/hbase/SortedInsertRewriter.java index 40789ac..a99d4d0 100644 --- a/tajo-storage/tajo-storage-hbase/src/main/java/org/apache/tajo/storage/hbase/SortedInsertRewriter.java +++ b/tajo-storage/tajo-storage-hbase/src/main/java/org/apache/tajo/storage/hbase/SortedInsertRewriter.java @@ -21,6 +21,8 @@ package org.apache.tajo.storage.hbase; import org.apache.tajo.catalog.Column; import org.apache.tajo.catalog.Schema; import org.apache.tajo.catalog.SortSpec; +import org.apache.tajo.exception.InvalidTablePropertyException; +import org.apache.tajo.exception.MissingTablePropertyException; import org.apache.tajo.exception.TajoException; import org.apache.tajo.exception.TajoInternalError; import org.apache.tajo.plan.LogicalPlan; @@ -53,7 +55,9 @@ public class SortedInsertRewriter implements LogicalPlanRewriteRule { return hbaseMode && node.getType() == NodeType.CREATE_TABLE || node.getType() == NodeType.INSERT; } - public static Column[] getIndexColumns(Schema tableSchema, KeyValueSet tableProperty) throws IOException { + public static Column[] getIndexColumns(Schema tableSchema, KeyValueSet tableProperty) + throws IOException, TajoException { + List<Column> indexColumns = new ArrayList<Column>(); ColumnMapping columnMapping = new ColumnMapping(tableSchema, tableProperty); http://git-wip-us.apache.org/repos/asf/tajo/blob/903151ea/tajo-storage/tajo-storage-hdfs/src/main/java/org/apache/tajo/storage/FileTablespace.java ---------------------------------------------------------------------- diff --git a/tajo-storage/tajo-storage-hdfs/src/main/java/org/apache/tajo/storage/FileTablespace.java b/tajo-storage/tajo-storage-hdfs/src/main/java/org/apache/tajo/storage/FileTablespace.java index e8a6c12..678675d 100644 --- a/tajo-storage/tajo-storage-hdfs/src/main/java/org/apache/tajo/storage/FileTablespace.java +++ b/tajo-storage/tajo-storage-hdfs/src/main/java/org/apache/tajo/storage/FileTablespace.java @@ -936,7 +936,7 @@ public class FileTablespace extends Tablespace { } @Override - public void verifySchemaToWrite(TableDesc tableDesc, Schema outSchema) throws IOException { + public void verifySchemaToWrite(TableDesc tableDesc, Schema outSchema) { } @Override http://git-wip-us.apache.org/repos/asf/tajo/blob/903151ea/tajo-storage/tajo-storage-hdfs/src/main/java/org/apache/tajo/storage/json/JsonLineDeserializer.java ---------------------------------------------------------------------- diff --git a/tajo-storage/tajo-storage-hdfs/src/main/java/org/apache/tajo/storage/json/JsonLineDeserializer.java b/tajo-storage/tajo-storage-hdfs/src/main/java/org/apache/tajo/storage/json/JsonLineDeserializer.java index 7ef483c..c720118 100644 --- a/tajo-storage/tajo-storage-hdfs/src/main/java/org/apache/tajo/storage/json/JsonLineDeserializer.java +++ b/tajo-storage/tajo-storage-hdfs/src/main/java/org/apache/tajo/storage/json/JsonLineDeserializer.java @@ -32,7 +32,7 @@ import org.apache.tajo.common.TajoDataTypes.Type; import org.apache.tajo.datum.DatumFactory; import org.apache.tajo.datum.NullDatum; import org.apache.tajo.datum.TextDatum; -import org.apache.tajo.exception.UnimplementedException; +import org.apache.tajo.exception.NotImplementedException; import org.apache.tajo.storage.Tuple; import org.apache.tajo.storage.text.TextLineDeserializer; import org.apache.tajo.storage.text.TextLineParsingError; @@ -208,7 +208,7 @@ public class JsonLineDeserializer extends TextLineDeserializer { break; default: - throw new UnimplementedException(types.get(fullPath).name() + " is not supported."); + throw new NotImplementedException(types.get(fullPath).name() + " is not supported."); } } http://git-wip-us.apache.org/repos/asf/tajo/blob/903151ea/tajo-storage/tajo-storage-hdfs/src/main/java/org/apache/tajo/storage/json/JsonLineSerializer.java ---------------------------------------------------------------------- diff --git a/tajo-storage/tajo-storage-hdfs/src/main/java/org/apache/tajo/storage/json/JsonLineSerializer.java b/tajo-storage/tajo-storage-hdfs/src/main/java/org/apache/tajo/storage/json/JsonLineSerializer.java index 99f81a2..0fd9e02 100644 --- a/tajo-storage/tajo-storage-hdfs/src/main/java/org/apache/tajo/storage/json/JsonLineSerializer.java +++ b/tajo-storage/tajo-storage-hdfs/src/main/java/org/apache/tajo/storage/json/JsonLineSerializer.java @@ -27,7 +27,7 @@ import org.apache.tajo.catalog.SchemaUtil; import org.apache.tajo.catalog.TableMeta; import org.apache.tajo.common.TajoDataTypes.Type; import org.apache.tajo.datum.TextDatum; -import org.apache.tajo.exception.UnimplementedException; +import org.apache.tajo.exception.NotImplementedException; import org.apache.tajo.storage.Tuple; import org.apache.tajo.storage.text.TextLineSerializer; @@ -119,7 +119,7 @@ public class JsonLineSerializer extends TextLineSerializer { break; default: - throw new UnimplementedException(fieldName + "(" + types.get(fullPath).name() + ") is not supported."); + throw new NotImplementedException(fieldName + "(" + types.get(fullPath).name() + ") is not supported."); } } http://git-wip-us.apache.org/repos/asf/tajo/blob/903151ea/tajo-storage/tajo-storage-hdfs/src/main/java/org/apache/tajo/storage/orc/ORCScanner.java ---------------------------------------------------------------------- diff --git a/tajo-storage/tajo-storage-hdfs/src/main/java/org/apache/tajo/storage/orc/ORCScanner.java b/tajo-storage/tajo-storage-hdfs/src/main/java/org/apache/tajo/storage/orc/ORCScanner.java index 9511071..dfb44d3 100644 --- a/tajo-storage/tajo-storage-hdfs/src/main/java/org/apache/tajo/storage/orc/ORCScanner.java +++ b/tajo-storage/tajo-storage-hdfs/src/main/java/org/apache/tajo/storage/orc/ORCScanner.java @@ -29,7 +29,7 @@ import org.apache.tajo.catalog.TableMeta; import org.apache.tajo.common.TajoDataTypes; import org.apache.tajo.conf.TajoConf; import org.apache.tajo.datum.*; -import org.apache.tajo.exception.UnimplementedException; +import org.apache.tajo.exception.NotImplementedException; import org.apache.tajo.plan.expr.EvalNode; import org.apache.tajo.storage.FileScanner; import org.apache.tajo.storage.StorageConstants; @@ -85,7 +85,7 @@ public class ORCScanner extends FileScanner { default: LOG.error("Not supported type for "+type.toString()); - throw new UnimplementedException("ORC type: "+type.toString()); + throw new NotImplementedException("ORC type: "+type.toString()); } } @@ -267,7 +267,7 @@ public class ORCScanner extends FileScanner { return NullDatum.get(); default: - throw new UnimplementedException("ORC type: "+type.toString()); + throw new NotImplementedException("ORC type: "+type.toString()); } } http://git-wip-us.apache.org/repos/asf/tajo/blob/903151ea/tajo-storage/tajo-storage-hdfs/src/main/java/org/apache/tajo/storage/text/DelimitedLineReader.java ---------------------------------------------------------------------- diff --git a/tajo-storage/tajo-storage-hdfs/src/main/java/org/apache/tajo/storage/text/DelimitedLineReader.java b/tajo-storage/tajo-storage-hdfs/src/main/java/org/apache/tajo/storage/text/DelimitedLineReader.java index 0443308..5b93c5c 100644 --- a/tajo-storage/tajo-storage-hdfs/src/main/java/org/apache/tajo/storage/text/DelimitedLineReader.java +++ b/tajo-storage/tajo-storage-hdfs/src/main/java/org/apache/tajo/storage/text/DelimitedLineReader.java @@ -31,7 +31,7 @@ import org.apache.hadoop.io.compress.CompressionCodecFactory; import org.apache.hadoop.io.compress.Decompressor; import org.apache.hadoop.io.compress.SplittableCompressionCodec; import org.apache.tajo.conf.TajoConf; -import org.apache.tajo.exception.UnimplementedException; +import org.apache.tajo.exception.NotImplementedException; import org.apache.tajo.exception.UnsupportedException; import org.apache.tajo.storage.*; import org.apache.tajo.storage.compress.CodecPool; @@ -72,7 +72,7 @@ public class DelimitedLineReader implements Closeable { this.bufferSize = bufferSize; if (this.codec instanceof SplittableCompressionCodec) { // bzip2 does not support multi-thread model - throw new UnimplementedException(this.getClass() + " does not support " + this.codec.getDefaultExtension()); + throw new NotImplementedException(this.getClass() + " does not support " + this.codec.getDefaultExtension()); } }
