Skip to content
Merged
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 @@ -18,16 +18,21 @@
package org.apache.doris.analysis;

import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import org.bouncycastle.util.Strings;

import java.util.List;
import java.util.Map;

public class TableScanParams {
public static final String PARAMS_NAME = "name";
public static String INCREMENTAL_READ = "incr";
public static String BRANCH = "branch";
public static String TAG = "tag";
public static final String INCREMENTAL_READ = "incr";
public static final String BRANCH = "branch";
public static final String TAG = "tag";
private static final ImmutableSet<String> VALID_PARAM_TYPES = ImmutableSet.of(
INCREMENTAL_READ,
BRANCH,
TAG);

private final String paramType;
// There are two ways to pass parameters to a function.
Expand All @@ -38,10 +43,18 @@ public class TableScanParams {
private final Map<String, String> mapParams;
private final List<String> listParams;

private void validate() {
if (!VALID_PARAM_TYPES.contains(paramType)) {
throw new IllegalArgumentException("Invalid param type: " + paramType);
}
// TODO: validate mapParams and listParams for different param types
}

public TableScanParams(String paramType, Map<String, String> mapParams, List<String> listParams) {
this.paramType = Strings.toLowerCase(paramType);
this.mapParams = mapParams == null ? ImmutableMap.of() : ImmutableMap.copyOf(mapParams);
this.listParams = listParams;
validate();
}

public List<String> getListParams() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,11 @@ suite("iceberg_query_tag_branch", "p0,external,doris,external_docker,external_do
sql """ select * from tag_branch_table@tag(b1) ; """
exception "does not have tag named b1"
}

test {
sql """ select * from tag_branch_table@brand(b1) ; """
exception "Invalid param type: brand"
}
}

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,11 @@ suite("paimon_time_travel", "p0,external,doris,external_docker,external_docker_d
exception "must contain key 'name' in params"
}

test {
sql """ select * from ${tableName}@brand('nme'='not_exists_branch'); """
exception "Invalid param type: brand"
}

} finally {
// sql """drop catalog if exists ${catalog_name}"""
}
Expand Down
Loading