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 @@ -39,6 +39,7 @@
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Random;
import java.util.Set;

Expand Down Expand Up @@ -112,6 +113,8 @@ private static QueryPlan getQueryPlan(String querySQL, String httpNode, StarRock
HttpPost post = new HttpPost(url);
post.setHeader("Content-Type", "application/json;charset=UTF-8");
post.setHeader("Authorization", getBasicAuthHeader(sourceOptions.getUsername(), sourceOptions.getPassword()));
Optional.ofNullable(sourceOptions.getWarehouseName())
.ifPresent(warehouse -> post.setHeader("warehouse", warehouse));
Copy link
Copy Markdown
Contributor Author

@zhangbutao zhangbutao Apr 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kevincai I refine this code to avoid setting warehouse header(null value) in case of flink sink table not having 'scan.params.warehouse'='warehosue_name'. And then fe will use the default_warehouse if not getting the warehouse header.

post.setEntity(new ByteArrayEntity(body.getBytes()));
try (CloseableHttpResponse response = httpClient.execute(post)) {
requsetCode = response.getStatusLine().getStatusCode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class StarRocksSourceOptions implements Serializable {
private final ReadableConfig tableOptions;
private final Map<String, String> tableOptionsMap;
private final Map<String, String> beScanProps = new HashMap<>();
public static final String SOURCE_PROPERTIES_PREFIX = "scan.params.";


// required Options
Expand All @@ -53,6 +54,9 @@ public class StarRocksSourceOptions implements Serializable {

public static final ConfigOption<String> TABLE_NAME = ConfigOptions.key("table-name")
.stringType().noDefaultValue().withDescription("Table name");

public static final ConfigOption<String> WAREHOUSE_NAME = ConfigOptions.key(SOURCE_PROPERTIES_PREFIX + "warehouse")
.stringType().noDefaultValue().withDescription("Warehouse name");


// optional Options
Expand Down Expand Up @@ -103,7 +107,6 @@ public class StarRocksSourceOptions implements Serializable {
.intType().defaultValue(1).withDescription("the max retry times if lookup database failed.");


public static final String SOURCE_PROPERTIES_PREFIX = "scan.params.";

public StarRocksSourceOptions(ReadableConfig options, Map<String, String> optionsMap) {
this.tableOptions = options;
Expand Down Expand Up @@ -167,6 +170,10 @@ public String getTableName() {
return tableOptions.get(TABLE_NAME);
}

public String getWarehouseName() {
return tableOptions.get(WAREHOUSE_NAME);
}


// optional Options
public int getConnectTimeoutMs() {
Expand Down