Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import org.apache.fluss.flink.sink.shuffle.DistributionMode;
import org.apache.fluss.flink.source.FlinkTableSource;
import org.apache.fluss.flink.utils.FlinkConnectorOptionsUtils;
import org.apache.fluss.metadata.DataLakeFormat;
import org.apache.fluss.metadata.TablePath;

import org.apache.flink.api.common.RuntimeExecutionMode;
Expand All @@ -48,20 +47,17 @@
import org.apache.flink.table.types.logical.RowType;

import java.time.ZoneId;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;

import static org.apache.fluss.config.ConfigOptions.TABLE_DATALAKE_FORMAT;
import static org.apache.fluss.config.ConfigOptions.TABLE_DELETE_BEHAVIOR;
import static org.apache.fluss.config.FlussConfigUtils.CLIENT_PREFIX;
import static org.apache.fluss.flink.catalog.FlinkCatalog.LAKE_TABLE_SPLITTER;
import static org.apache.fluss.flink.utils.DataLakeUtils.getDatalakeFormat;
import static org.apache.fluss.flink.utils.FlinkConnectorOptionsUtils.getBucketKeyIndexes;
import static org.apache.fluss.flink.utils.FlinkConnectorOptionsUtils.getBucketKeys;
import static org.apache.fluss.flink.utils.FlinkConversions.toFlinkOption;
Expand Down Expand Up @@ -92,11 +88,6 @@ public DynamicTableSource createDynamicTableSource(Context context) {

FactoryUtil.TableFactoryHelper helper = FactoryUtil.createTableFactoryHelper(this, context);
final ReadableConfig tableOptions = helper.getOptions();
Optional<DataLakeFormat> datalakeFormat = getDatalakeFormat(tableOptions);
List<String> prefixesToSkip =
new ArrayList<>(Arrays.asList("table.", "client.", "fields."));
datalakeFormat.ifPresent(dataLakeFormat -> prefixesToSkip.add(dataLakeFormat + "."));
helper.validateExcept(prefixesToSkip.toArray(new String[0]));

boolean isStreamingMode =
context.getConfiguration().get(ExecutionOptions.RUNTIME_MODE)
Expand Down Expand Up @@ -160,12 +151,6 @@ public DynamicTableSource createDynamicTableSource(Context context) {
public DynamicTableSink createDynamicTableSink(Context context) {
FactoryUtil.TableFactoryHelper helper = FactoryUtil.createTableFactoryHelper(this, context);
final ReadableConfig tableOptions = helper.getOptions();
Optional<DataLakeFormat> datalakeFormat = getDatalakeFormat(tableOptions);
if (datalakeFormat.isPresent()) {
helper.validateExcept("table.", "client.", "fields.", datalakeFormat.get() + ".");
} else {
helper.validateExcept("table.", "client.", "fields.");
}

boolean isStreamingMode =
context.getConfiguration().get(ExecutionOptions.RUNTIME_MODE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -757,20 +757,11 @@ void testCreateTableWithUnknownOptions() {
"create table test_table_other_unknown_options (a int, b int)"
+ " with ('connector' = 'fluss', 'bootstrap.servers' = 'localhost:9092', 'other.unknown.option' = 'other-unknown-val')");

// test invalid table as source
assertThatThrownBy(() -> tEnv.explainSql("select * from test_table_other_unknown_options"))
.cause()
.isInstanceOf(ValidationException.class)
.hasMessageContaining("Unsupported options found for 'fluss'");
// test table with unknown option as source
tEnv.explainSql("select * from test_table_other_unknown_options");

// test invalid table as sink
assertThatThrownBy(
() ->
tEnv.explainSql(
"insert into test_table_other_unknown_options values (1, 2)"))
.cause()
.isInstanceOf(ValidationException.class)
.hasMessageContaining("Unsupported options found for 'fluss'");
// test table with unknown option as sink
tEnv.explainSql("insert into test_table_other_unknown_options values (1, 2)");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,8 @@ void testTableSourceOptions() {
Map<String, String> validProperties = getBasicOptions();
validProperties.put("k1", "v1");

// test invalid options
assertThatThrownBy(() -> createTableSource(schema, validProperties))
.isInstanceOf(ValidationException.class)
.hasMessageContaining("Unsupported options:\n" + "\n" + "k1");
// test create table source with custom properties is ok
createTableSource(schema, validProperties);

// test scan startup mode options
Map<String, String> scanModeProperties = getBasicOptions();
Expand Down Expand Up @@ -178,6 +176,10 @@ void testSink() {
List<String> bucketKeys = tableSink.getBucketKeys();
assertThat(bucketKeys)
.isEqualTo(Arrays.asList(properties.get(BUCKET_KEY.key()).split(",")));

// test create table sink with custom properties is ok
properties.put("k1", "v1");
createTableSink(schema, properties);
}

private ResolvedSchema createBasicSchema() {
Expand Down