use of org.apache.flink.table.api.internal.TableEnvironmentInternal in project zeppelin by apache.
the class Flink112Shims method parseSql.
/**
* Parse it via flink SqlParser first, then fallback to regular expression matching.
*
* @param tableEnv
* @param stmt
* @return
*/
@Override
public Optional<SqlCommandParser.SqlCommandCall> parseSql(Object tableEnv, String stmt) {
Parser sqlParser = ((TableEnvironmentInternal) tableEnv).getParser();
SqlCommandCall sqlCommandCall = null;
try {
// parse statement via regex matching first
Optional<SqlCommandCall> callOpt = parseByRegexMatching(stmt);
if (callOpt.isPresent()) {
sqlCommandCall = callOpt.get();
} else {
sqlCommandCall = parseBySqlParser(sqlParser, stmt);
}
} catch (Exception e) {
return Optional.empty();
}
return Optional.of(sqlCommandCall);
}
use of org.apache.flink.table.api.internal.TableEnvironmentInternal in project flink by apache.
the class LocalExecutor method parseStatement.
@Override
public Operation parseStatement(String sessionId, String statement) throws SqlExecutionException {
final ExecutionContext context = getExecutionContext(sessionId);
final TableEnvironment tableEnv = context.getTableEnvironment();
Parser parser = ((TableEnvironmentInternal) tableEnv).getParser();
List<Operation> operations;
try {
operations = context.wrapClassLoader(() -> parser.parse(statement));
} catch (Exception e) {
throw new SqlExecutionException("Failed to parse statement: " + statement, e);
}
if (operations.isEmpty()) {
throw new SqlExecutionException("Failed to parse statement: " + statement);
}
return operations.get(0);
}
use of org.apache.flink.table.api.internal.TableEnvironmentInternal in project flink by apache.
the class LocalExecutor method executeModifyOperations.
@Override
public TableResultInternal executeModifyOperations(String sessionId, List<ModifyOperation> operations) throws SqlExecutionException {
final ExecutionContext context = getExecutionContext(sessionId);
final TableEnvironmentInternal tEnv = (TableEnvironmentInternal) context.getTableEnvironment();
try {
return context.wrapClassLoader(() -> tEnv.executeInternal(operations));
} catch (Exception e) {
throw new SqlExecutionException(MESSAGE_SQL_EXECUTION_ERROR, e);
}
}
Aggregations