Skip to content
This repository was archived by the owner on May 12, 2021. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
3572068
Add array type in sql parser.
hyunsik Apr 21, 2016
10f38bb
Move some methods in FieldConverter to TypeConverter
hyunsik Apr 21, 2016
dbcf07a
Add SchemaConverter.
hyunsik Apr 21, 2016
63b1711
Remove unused imports.
hyunsik Apr 21, 2016
5f6b8f3
Refactor Struct Type.
hyunsik Apr 21, 2016
0659881
Refactor convertDataType to return Type instead of DataType.
hyunsik Apr 21, 2016
c8af0b4
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/tajo…
hyunsik Apr 22, 2016
30b30c2
Extracted Field from Schema to an upper class.
hyunsik Apr 22, 2016
75e679e
Add QualifiedIdentifier::raw().
hyunsik Apr 22, 2016
89a1e95
Refactor Identifier codes
hyunsik Apr 23, 2016
3c94e20
Fix hash problem and the comparator of SortSpec.
hyunsik Apr 25, 2016
6f1e5fc
Fix failed unit tests.
hyunsik Apr 25, 2016
6702ead
Add array unit test to TestCreateTable.
hyunsik Apr 26, 2016
c74af8a
Change TypeDesc to Type.
hyunsik Apr 26, 2016
4a5056e
Implement TypeSerializer and its relevant classes.
hyunsik May 2, 2016
7645d45
Add TypeAdapter to transform Type to Json documentation.
hyunsik May 3, 2016
129213d
Fix all unit tests.
hyunsik May 6, 2016
a0924a4
Add TypeStringEncoder and TypeProtobufEncoder.
hyunsik May 10, 2016
8f4914f
Applied new Type to catalog.
hyunsik May 10, 2016
1dec9b8
Fixed all unit tests.
hyunsik May 10, 2016
518c525
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/tajo…
hyunsik May 11, 2016
7091b40
Removed SchemaConverter.
hyunsik May 11, 2016
8c94846
Renames *Encoder and clean up.
hyunsik May 11, 2016
54b639a
Updated schema history.
hyunsik May 11, 2016
19cd883
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/tajo…
hyunsik May 11, 2016
6a8e747
Reflected comments.
hyunsik May 13, 2016
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 @@ -24,11 +24,6 @@ public class ColumnDefinition extends DataTypeExpr {
@Expose @SerializedName("ColumnDefName")
String columnName;

public ColumnDefinition(String columnName, String dataType) {
super(dataType);
this.columnName = columnName;
}

public ColumnDefinition(String columnName, DataTypeExpr dataType) {
super(dataType.getTypeName());

Expand All @@ -42,15 +37,17 @@ public ColumnDefinition(String columnName, DataTypeExpr dataType) {
}
}

// nested records
if (dataType.isRecordType()) {
this.recordType = dataType.recordType;
}

// map type
if (dataType.isMapType()) {
this.mapType = dataType.mapType;
}

if (dataType.isArrayType()) {
this.arrayType = dataType.arrayType;
}
}

public String getColumnName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,37 +19,52 @@
package org.apache.tajo.algebra;

import com.google.common.base.Objects;
import com.google.common.base.Preconditions;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import org.apache.tajo.Assert;
import org.apache.tajo.common.TajoDataTypes.Type;
import org.apache.tajo.util.TUtil;

import static org.apache.tajo.Assert.assertNotNull;

public class DataTypeExpr extends Expr {
@Expose @SerializedName("DataTypeName")
String typeName;
@Expose @SerializedName("LengthOrPrecision")
Integer lengthOrPrecision;
@Expose @SerializedName("Scale")
Integer scale;
@Expose @SerializedName("Array")
ArrayType arrayType; // not null if the type is ARRAY
@Expose @SerializedName("Record")
RecordType recordType; // not null if the type is RECORD
@Expose @SerializedName("Map")
MapType mapType;

public DataTypeExpr(String typeName) {
super(OpType.DataType);
assertNotNull(typeName);
this.typeName = typeName;
}

public DataTypeExpr(ArrayType array) {
super(OpType.DataType);
assertNotNull(array);
this.typeName = Type.ARRAY.name();
this.arrayType = array;
}

public DataTypeExpr(RecordType record) {
super(OpType.DataType);
assertNotNull(record);
this.typeName = Type.RECORD.name();
this.recordType = record;
}

public DataTypeExpr(MapType map) {
super(OpType.DataType);
// RECORD = 51 in DataTypes.proto
assertNotNull(map);
this.typeName = Type.MAP.name();
this.mapType = map;
}
Expand All @@ -59,15 +74,34 @@ public String getTypeName() {
}

public boolean isPrimitiveType() {
return !this.isRecordType() && !isMapType();
return !isArrayType()&& !isRecordType() && !isMapType();
}

public boolean isArrayType() {
return arrayType != null;
}

public boolean isRecordType() {
return this.typeName.equals(Type.RECORD.name());
return recordType != null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this method be frequently called? It seems not, and I think it would be better to check the type name because we can figure out when the type is record but recordType is null.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the comment. I fixed it.

}

public boolean isMapType() {
return this.typeName.equals(Type.MAP.name());
return mapType != null;
}

public DataTypeExpr getElementType() {
Preconditions.checkState(isArrayType());
return arrayType.type;
}

public DataTypeExpr getKeyType() {
Preconditions.checkState(isMapType());
return mapType.keyType;
}

public DataTypeExpr getValueType() {
Preconditions.checkState(isMapType());
return mapType.valueType;
}

public ColumnDefinition [] getNestedRecordTypes() {
Expand Down Expand Up @@ -125,6 +159,27 @@ public Object clone() throws CloneNotSupportedException {
return dataType;
}

public static class ArrayType implements JsonSerializable, Cloneable {
@Expose
@SerializedName("type")
DataTypeExpr type;

public ArrayType(DataTypeExpr elementType) {
this.type = elementType;
}

@Override
public String toJson() {
return JsonHelper.toJson(this);
}

public Object clone() throws CloneNotSupportedException {
ArrayType newMap = (ArrayType) super.clone();
newMap.type = type;
return newMap;
}
}

public static class RecordType implements JsonSerializable, Cloneable {
@Expose @SerializedName("Schema")
ColumnDefinition [] schema; // not null if the type is RECORD
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.apache.tajo.rpc.protocolrecords.PrimitiveProtos.NullProto;
import org.apache.tajo.rpc.protocolrecords.PrimitiveProtos.ReturnState;
import org.apache.tajo.rpc.protocolrecords.PrimitiveProtos.StringListResponse;
import org.apache.tajo.schema.IdentifierUtil;
import org.apache.tajo.util.ProtoUtil;

import java.io.Closeable;
Expand Down Expand Up @@ -281,7 +282,7 @@ public final TableDesc getTableDesc(final String databaseName, final String tabl

@Override
public TableDesc getTableDesc(String qualifiedName) throws UndefinedTableException {
String[] splitted = CatalogUtil.splitFQTableName(qualifiedName);
String[] splitted = IdentifierUtil.splitFQTableName(qualifiedName);
return getTableDesc(splitted[0], splitted[1]);
}

Expand Down Expand Up @@ -596,7 +597,7 @@ public final void createTable(final TableDesc desc)
public void dropTable(String tableName)
throws UndefinedDatabaseException, UndefinedTableException, InsufficientPrivilegeException {

String[] splitted = CatalogUtil.splitFQTableName(tableName);
String[] splitted = IdentifierUtil.splitFQTableName(tableName);
final String databaseName = splitted[0];
final String simpleName = splitted[1];

Expand All @@ -617,7 +618,7 @@ public void dropTable(String tableName)

@Override
public final boolean existsTable(final String databaseName, final String tableName) {
if (CatalogUtil.isFQTableName(tableName)) {
if (IdentifierUtil.isFQTableName(tableName)) {
throw new IllegalArgumentException(
"tableName cannot be composed of multiple parts, but it is \"" + tableName + "\"");
}
Expand All @@ -640,7 +641,7 @@ public final boolean existsTable(final String databaseName, final String tableNa

@Override
public final boolean existsTable(final String tableName) {
String[] splitted = CatalogUtil.splitFQTableName(tableName);
String[] splitted = IdentifierUtil.splitFQTableName(tableName);
return existsTable(splitted[0], splitted[1]);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ public static boolean isUpperCastable(TajoDataTypes.Type define, TajoDataTypes.T
*/
public static org.apache.tajo.type.Type determineType(org.apache.tajo.type.Type left,
org.apache.tajo.type.Type right) {
TajoDataTypes.Type rhsBaseType = right.baseType();
switch (left.baseType()) {
TajoDataTypes.Type rhsBaseType = right.kind();
switch (left.kind()) {

case INT1:
case INT2:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
package org.apache.tajo.catalog;

public class CatalogConstants {
public final static String IDENTIFIER_DELIMITER_REGEXP = "\\.";
public final static String IDENTIFIER_DELIMITER = ".";
public final static String IDENTIFIER_QUOTE_STRING = "\"";
public final static int MAX_IDENTIFIER_LENGTH = 128;
// Linux and BSD's max username length is 32. For compatibility with other systems, we should follow it.
public final static int MAX_USERNAME_LENGTH = 32;
public final static int MAX_STATEMENT_LENGTH = 128 * 1024;
Expand Down
Loading