51nb / marble Goto Github PK
View Code? Open in Web Editor NEWA high performance in-memory hive sql engine based on Apache Calcite
License: Apache License 2.0
A high performance in-memory hive sql engine based on Apache Calcite
License: Apache License 2.0
@test
public void testCreateTableFromRowListWithSqlType() {
List<Map<String, Object>> rowList = new ArrayList<>();
Map<String, Object> row1 = new HashMap<>();
row1.put("c1", "a");
row1.put("c2", 0.1);
row1.put("c3", new Date().getTime());
row1.put("c4", Lists.newArrayList("a", "n"));
rowList.add(row1);
Map<String, Object> row2 = new HashMap<>();
row2.put("c1", "b");
row2.put("c2", 0.2);
row2.put("c3", new Date().getTime());
row1.put("c4", Lists.newArrayList("a", "n"));
rowList.add(row2);
Map<String, SqlTypeName> sqlTypeMap = new HashMap<>();
sqlTypeMap.put("c1", SqlTypeName.VARCHAR);
sqlTypeMap.put("c2", SqlTypeName.DOUBLE);
sqlTypeMap.put("c3", SqlTypeName.TIMESTAMP);
sqlTypeMap.put("c4", SqlTypeName.ARRAY);
DataTable dataTable = tableEnv.fromRowListWithSqlTypeMap(rowList, sqlTypeMap);
tableEnv.registerTable("t", dataTable);
DataTable queryResult = tableEnv.sqlQuery("select * from t");
System.out.println(queryResult.toMapList());
}
测试报错
java.lang.AssertionError: use createArrayType() instead
at org.apache.calcite.sql.type.SqlTypeFactoryImpl.assertBasic(SqlTypeFactoryImpl.java:221)
at org.apache.calcite.sql.type.SqlTypeFactoryImpl.createSqlType(SqlTypeFactoryImpl.java:48)
at org.apache.calcite.rel.type.RelDataTypeFactory$Builder.add(RelDataTypeFactory.java:476)
at org.apache.calcite.rel.type.RelDataTypeFactory$FieldInfoBuilder.add(RelDataTypeFactory.java:377)
at org.apache.calcite.rel.type.RelDataTypeFactory$FieldInfoBuilder.add(RelDataTypeFactory.java:365)
at org.apache.calcite.table.TableEnv.lambda$fromRowListWithSqlTypeMap$2(TableEnv.java:557)
at java.util.ArrayList.forEach(ArrayList.java:1249)
at org.apache.calcite.table.TableEnv.fromRowListWithSqlTypeMap(TableEnv.java:556)
at org.apache.calcite.table.TableEnvTest.testCreateTableFromRowListWithSqlType(TableEnvTest.java:98)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Add sql type hint annotations for Java Pojo , like
@ColumnType(SqlTypeName.TIMESTAMP) private Long createTime;
tableEnv.registerTable是否有并发安全问题?
Support caching for same query template with different parameters, like PreparedStatement in JDBC interface.
Caused by: java.lang.UnsupportedOperationException: class org.apache.calcite.sql.SqlIdentifier: string
let TableEnv register custom Schema, to accept various datasource,such as JDBC datasource, MongoDB,or other adapters of Calcite. So some computation can be pushed down to the datasource.
select * from [ table_name] sample 1
Let TableEnv register a ViewTable .
Consider a specific useCase, in sql it seems like:
create view v1 as select id, udf(content) as c1 from t1
when we executing a query like
select * from t2 join v1 on t2.id=v1.id and v1.id<10000
the predicate condition v1.id<10000
can be pushed down.
The final sql will be
select * from t2 join (select id, udf(content) as c1 from t1 where id<10000)v1 on t2.id=v1.id
,
so the cost can be reduced.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.