Java Code Examples for org.apache.flink.table.client.config.entries.TemporalTableEntry#getName()

The following examples show how to use org.apache.flink.table.client.config.entries.TemporalTableEntry#getName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExecutionContext.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
private void registerTemporalTable(TemporalTableEntry temporalTableEntry) {
	try {
		final Table table = tableEnv.scan(temporalTableEntry.getHistoryTable());
		final TableFunction<?> function = table.createTemporalTableFunction(
			temporalTableEntry.getTimeAttribute(),
			String.join(",", temporalTableEntry.getPrimaryKeyFields()));
		if (tableEnv instanceof StreamTableEnvironment) {
			StreamTableEnvironment streamTableEnvironment = (StreamTableEnvironment) tableEnv;
			streamTableEnvironment.registerFunction(temporalTableEntry.getName(), function);
		} else {
			BatchTableEnvironment batchTableEnvironment = (BatchTableEnvironment) tableEnv;
			batchTableEnvironment.registerFunction(temporalTableEntry.getName(), function);
		}
	} catch (Exception e) {
		throw new SqlExecutionException(
			"Invalid temporal table '" + temporalTableEntry.getName() + "' over table '" +
				temporalTableEntry.getHistoryTable() + ".\nCause: " + e.getMessage());
	}
}
 
Example 2
Source File: ExecutionContext.java    From flink with Apache License 2.0 6 votes vote down vote up
private void registerTemporalTable(TemporalTableEntry temporalTableEntry) {
	try {
		final Table table = tableEnv.scan(temporalTableEntry.getHistoryTable());
		final TableFunction<?> function = table.createTemporalTableFunction(
			temporalTableEntry.getTimeAttribute(),
			String.join(",", temporalTableEntry.getPrimaryKeyFields()));
		if (tableEnv instanceof StreamTableEnvironment) {
			StreamTableEnvironment streamTableEnvironment = (StreamTableEnvironment) tableEnv;
			streamTableEnvironment.registerFunction(temporalTableEntry.getName(), function);
		} else {
			BatchTableEnvironment batchTableEnvironment = (BatchTableEnvironment) tableEnv;
			batchTableEnvironment.registerFunction(temporalTableEntry.getName(), function);
		}
	} catch (Exception e) {
		throw new SqlExecutionException(
			"Invalid temporal table '" + temporalTableEntry.getName() + "' over table '" +
				temporalTableEntry.getHistoryTable() + ".\nCause: " + e.getMessage());
	}
}
 
Example 3
Source File: ExecutionContext.java    From flink with Apache License 2.0 6 votes vote down vote up
private void registerTemporalTable(TemporalTableEntry temporalTableEntry) {
	try {
		final Table table = tableEnv.from(temporalTableEntry.getHistoryTable());
		List<String> primaryKeyFields = temporalTableEntry.getPrimaryKeyFields();
		if (primaryKeyFields.size() > 1) {
			throw new ValidationException("Temporal tables over a composite primary key are not supported yet.");
		}
		final TableFunction<?> function = table.createTemporalTableFunction(
			$(temporalTableEntry.getTimeAttribute()),
			$(primaryKeyFields.get(0)));
		if (tableEnv instanceof StreamTableEnvironment) {
			StreamTableEnvironment streamTableEnvironment = (StreamTableEnvironment) tableEnv;
			streamTableEnvironment.registerFunction(temporalTableEntry.getName(), function);
		} else {
			BatchTableEnvironment batchTableEnvironment = (BatchTableEnvironment) tableEnv;
			batchTableEnvironment.registerFunction(temporalTableEntry.getName(), function);
		}
	} catch (Exception e) {
		throw new SqlExecutionException(
			"Invalid temporal table '" + temporalTableEntry.getName() + "' over table '" +
				temporalTableEntry.getHistoryTable() + ".\nCause: " + e.getMessage());
	}
}