public static Schema sortSpecsToSchema(SortSpec[] sortSpecs) { return SchemaBuilder.builder().addAll(sortSpecs, new Function<SortSpec, Column>() { @Override public Column apply(@Nullable SortSpec input) { return input.getSortKey(); } }).build(); }
private static Schema getNaturalJoinSchema(LogicalNode left, LogicalNode right) { SchemaBuilder joinSchema = SchemaBuilder.uniqueNameBuilder(); joinSchema.addAll(left.getOutSchema().getRootColumns()); joinSchema.addAll(right.getOutSchema().getRootColumns()); return joinSchema.build(); }
private Schema sortSchema(Schema schema) { Column[] columns = schema.toArray(); Arrays.sort(columns, columnComparator); return SchemaBuilder.builder().addAll(columns).build(); }
public IndexScanInfo(TableStats tableStats, IndexDesc indexDesc, SimplePredicate[] predicates) { super(ScanTypeControl.INDEX_SCAN, tableStats); this.indexPath = indexDesc.getIndexPath(); this.predicates = predicates; keySchema = SchemaBuilder.builder().addAll(predicates, new Function<SimplePredicate, Column>() { @Override public Column apply(@Nullable SimplePredicate p) { return p.getKeySortSpec().getSortKey(); } }).build(); }
public TajoMetaDataResultSet(List<String> columns, List<Type> types, List<MetaDataTuple> values) { super(null, SchemaBuilder.empty(), null); SchemaBuilder builder = SchemaBuilder.builder(); int index = 0; if(columns != null) { for(String columnName: columns) { builder.add(columnName, types.get(index++)); } } this.schema = builder.build(); setDataTuples(values); }
public static Schema getQualifiedLogicalSchema(TableDesc tableDesc, String tableName) { Schema logicalSchema = SchemaBuilder.builder().addAll(tableDesc.getLogicalSchema().getRootColumns()).build(); if (tableName != null) { logicalSchema.setQualifier(tableName); } return logicalSchema; }
@Test public void testIsNullPredicate() throws TajoException { Schema schema1 = SchemaBuilder.builder() .add("col1", INT4) .add("col2", INT4) .build(); testEval(schema1, "table1", "123,", "select col1 is null, col2 is null as a from table1", new String[]{"f", "t"}); testEval(schema1, "table1", "123,", "select col1 is not null, col2 is not null as a from table1", new String[]{"t", "f"}); }
@Test public void testNullHandling2() throws TajoException { Schema schema = SchemaBuilder.builder() .add("col1", BOOLEAN) .build(); testEval(schema, "table1", "", "select null_test() from table1", new String[]{NullDatum.get().toString()}); } }
@Test public void testQuotedIdentifiers() throws TajoException { Schema schema = SchemaBuilder.builder() .add("컬럼1", TEXT) .add("컬럼2", TEXT).build(); testEval(schema, "테이블1", "123,234", "select \"컬럼1\"::float, cast (\"컬럼2\" as float4) as a from \"테이블1\"", new String[]{"123.0", "234.0"}); testEval(schema, "테이블1", "123,234", "select char_length(\"컬럼1\"), \"컬럼2\"::float4 as \"별명1\" from \"테이블1\"", new String[]{"3", "234.0"}); }
@Test public void testStringConcat() throws TajoException { testSimpleEval("select length('123456') as col1 ", new String[]{"6"}); testEval(schema, "table1", "0,1,2,3,4.5,6.5", "select 'abc' || 'bbc'", new String [] {"abcbbc"}); Schema schema = SchemaBuilder.builder() .add("col1", TajoDataTypes.Type.TEXT) .add("col2", TajoDataTypes.Type.TEXT) .build(); testEval(schema, "table1", " trim, abc", "select ltrim(col1) || ltrim(col2) from table1", new String[]{"trimabc"}); } }
@Test public void testCharLength() throws TajoException { testSimpleEval("select char_length('123456') as col1 ", new String[]{"6"}); Schema schema = SchemaBuilder.builder() .add("col1", TEXT) .add("col2", TEXT) .add("col3", TEXT) .build(); testEval(schema, "table1", "ABC,DEF,3.14", "select character_length(lower(col1) || lower(col2)) from table1", new String[]{"6"}); }
@Test public void testLength() throws TajoException { testSimpleEval("select length('123456') as col1 ", new String[]{"6"}); Schema schema = SchemaBuilder.builder() .add("col1", TEXT) .add("col2", TEXT) .add("col3", TEXT) .build(); testEval(schema, "table1", "ABC,DEF,3.14", "select length(lower(col1) || lower(col2)) from table1", new String[]{"6"}); }
@Test public void testLower() throws TajoException { testSimpleEval("select lower('ABCdEF') as col1 ", new String[]{"abcdef"}); Schema schema = SchemaBuilder.builder() .add("col1", TEXT) .add("col2", TEXT) .add("col3", TEXT) .build(); testEval(schema, "table1", "ABC,DEF,3.14", "select lower(col1), lower(col2) from table1", new String[]{"abc", "def"}); testEval(schema, "table1", "ABC,DEF,3.14", "select lower(col1) || lower(col2) from table1", new String[]{"abcdef"}); }
@Test public void testMd5() throws TajoException { testSimpleEval("select md5('1') as col1 ", new String[]{"c4ca4238a0b923820dcc509a6f75849b"}); testSimpleEval("select md5('tajo') as col1 ", new String[]{"742721b3a79f71a9491681b8e8a7ce85"}); Schema schema = SchemaBuilder.builder() .add("col1", TEXT) .add("col2", TEXT) .add("col3", TEXT) .build(); testEval(schema, "table1", "abc,efg,3.14", "select md5(col1) from table1", new String[]{"900150983cd24fb0d6963f7d28e17f72"}); }
@BeforeClass public static void setupClass() { Column col0 = new Column("col0", Type.BOOLEAN); Column col1 = new Column("col1", Type.INT4); Column col2 = new Column("col2", Type.INT8); Column col3 = new Column("col3", Type.FLOAT4); Column col4 = new Column("col4", Type.FLOAT8); schema = SchemaBuilder.builder().addAll(new Column[]{col0, col1, col2, col3, col4}).build(); }
@Test public void testRepeat() throws TajoException { testSimpleEval("select repeat('ab',4) as col1 ", new String[]{"abababab"}); testSimpleEval("select repeat('가',3) as col1 ", new String[]{"가가가"}); testSimpleEval("select repeat('a',2) as col1 ", new String[]{"aa"}); Schema schema = SchemaBuilder.builder() .add("col1", TEXT) .add("col2", TEXT) .add("col3", TEXT) .build(); testEval(schema, "table1", "abc,efg,3.14", "select repeat(col1,2) from table1", new String[]{"abcabc"}); }
@Test public void testChr() throws TajoException { testSimpleEval("select chr(48) as col1 ", new String[]{"0"}); testSimpleEval("select chr(49) as col1 ", new String[]{"1"}); testSimpleEval("select chr(50) as col1 ", new String[]{"2"}); testSimpleEval("select chr(64) as col1 ", new String[]{"@"}); Schema schema = SchemaBuilder.builder() .add("col1", INT4).build(); testEval(schema, "table1", "65", "select chr(col1) from table1", new String[]{"A"}); testEval(schema, "table1", "66", "select chr(col1) from table1", new String[]{"B"}); testEval(schema, "table1", "52512", "select chr(col1) from table1", new String[]{"촠"}); }
public TestBSTIndex(String type) { this.dataFormat = type; conf = new TajoConf(); conf.setVar(TajoConf.ConfVars.ROOT_DIR, TEST_PATH); schema = SchemaBuilder.builder() .add(new Column("int", Type.INT4)) .add(new Column("long", Type.INT8)) .add(new Column("double", Type.FLOAT8)) .add(new Column("float", Type.FLOAT4)) .add(new Column("string", Type.TEXT)) .build(); }
public TestSingleCSVFileBSTIndex() { conf = new TajoConf(); conf.setVar(ConfVars.ROOT_DIR, TEST_PATH); schema = SchemaBuilder.builder() .add(new Column("int", Type.INT4)) .add(new Column("long", Type.INT8)) .add(new Column("double", Type.FLOAT8)) .add(new Column("float", Type.FLOAT4)) .add(new Column("string", Type.TEXT)) .build(); }
private Schema createAllTypesConvertedSchema() { return SchemaBuilder.builder() .add(new Column("myboolean", Type.BOOLEAN)) .add(new Column("myint", Type.INT4)) .add(new Column("mylong", Type.INT8)) .add(new Column("myfloat", Type.FLOAT4)) .add(new Column("mydouble", Type.FLOAT8)) .add(new Column("mybytes", Type.BLOB)) .add(new Column("mystring", Type.TEXT)) .add(new Column("myfixed", Type.BLOB)) .build(); }