@Internal @Experimental public class BeamSqlEnv extends java.lang.Object
BeamSqlEnv
prepares the execution context for BeamSql
and BeamSqlCli
.
It contains a SchemaPlus
which holds the metadata of tables/UDF functions, and a
BeamQueryPlanner
which parse/validate/optimize/translate input SQL queries.
Modifier and Type | Method and Description |
---|---|
void |
executeDdl(java.lang.String sqlStatement) |
java.lang.String |
explain(java.lang.String sqlString) |
org.apache.calcite.jdbc.CalcitePrepare.Context |
getContext() |
static BeamSqlEnv |
inMemory(TableProvider... tableProviders) |
boolean |
isDdl(java.lang.String sqlStatement) |
PTransform<PCollectionTuple,PCollection<Row>> |
parseQuery(java.lang.String query) |
static BeamSqlEnv |
readOnly(java.lang.String tableType,
java.util.Map<java.lang.String,BeamSqlTable> tables) |
void |
registerUdaf(java.lang.String functionName,
Combine.CombineFn combineFn)
Register a UDAF function which can be used in GROUP-BY expression.
|
void |
registerUdf(java.lang.String functionName,
java.lang.Class<?> clazz,
java.lang.String method)
Register a UDF function which can be used in SQL expression.
|
void |
registerUdf(java.lang.String functionName,
java.lang.Class<? extends BeamSqlUdf> clazz)
Register a UDF function which can be used in SQL expression.
|
void |
registerUdf(java.lang.String functionName,
SerializableFunction sfn)
Register
SerializableFunction as a UDF function which can be used in SQL expression. |
static BeamSqlEnv |
withTableProvider(TableProvider tableProvider) |
public static BeamSqlEnv readOnly(java.lang.String tableType, java.util.Map<java.lang.String,BeamSqlTable> tables)
public static BeamSqlEnv withTableProvider(TableProvider tableProvider)
public static BeamSqlEnv inMemory(TableProvider... tableProviders)
public void registerUdf(java.lang.String functionName, java.lang.Class<?> clazz, java.lang.String method)
public void registerUdf(java.lang.String functionName, java.lang.Class<? extends BeamSqlUdf> clazz)
public void registerUdf(java.lang.String functionName, SerializableFunction sfn)
SerializableFunction
as a UDF function which can be used in SQL expression.
Note, SerializableFunction
must have a constructor without arguments.public void registerUdaf(java.lang.String functionName, Combine.CombineFn combineFn)
Combine.CombineFn
on how to implement a UDAF.public PTransform<PCollectionTuple,PCollection<Row>> parseQuery(java.lang.String query) throws ParseException
ParseException
public boolean isDdl(java.lang.String sqlStatement) throws ParseException
ParseException
public void executeDdl(java.lang.String sqlStatement) throws ParseException
ParseException
public org.apache.calcite.jdbc.CalcitePrepare.Context getContext()
public java.lang.String explain(java.lang.String sqlString) throws ParseException
ParseException