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 @@ -91,8 +91,17 @@ protected List<SourceConfig> getSourceConfigs() throws DataVinesException {
if (tableArray.length == 1) {
metricInputParameter.put(TABLE, tableArray[0]);
} else {
metricInputParameter.put(DATABASE, tableArray[0]);
metricInputParameter.put(TABLE, tableArray[1]);
String connectorSchema = connectorParameter.getParameters().get(SCHEMA) != null ?
(String)connectorParameter.getParameters().get(SCHEMA) : null;
if (connectorSchema != null && connectorSchema.equals(tableArray[0])) {
// When the table name from SQL already includes the schema prefix
// (e.g., "schema.table"), and it matches the configured schema,
// treat it as schema.table, not database.table
metricInputParameter.put(TABLE, tableArray[1]);
} else {
metricInputParameter.put(DATABASE, tableArray[0]);
metricInputParameter.put(TABLE, tableArray[1]);
}
}

SourceConfig sourceConfig = new SourceConfig();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,17 @@ protected List<SourceConfig> getSourceConfigs() throws DataVinesException {
if (tableArray.length == 1) {
metricInputParameter.put(TABLE, tableArray[0]);
} else {
metricInputParameter.put(DATABASE, tableArray[0]);
metricInputParameter.put(TABLE, tableArray[1]);
String connectorSchema = connectorParameter.getParameters().get(SCHEMA) != null ?
(String)connectorParameter.getParameters().get(SCHEMA) : null;
if (connectorSchema != null && connectorSchema.equals(tableArray[0])) {
// When the table name from SQL already includes the schema prefix
// (e.g., "schema.table"), and it matches the configured schema,
// treat it as schema.table, not database.table
metricInputParameter.put(TABLE, tableArray[1]);
} else {
metricInputParameter.put(DATABASE, tableArray[0]);
metricInputParameter.put(TABLE, tableArray[1]);
}
}

Map<String, Object> connectorParameterMap = new HashMap<>(connectorParameter.getParameters());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,17 @@ protected List<SourceConfig> getSourceConfigs() throws DataVinesException {
if (tableArray.length == 1) {
metricInputParameter.put(TABLE, tableArray[0]);
} else {
metricInputParameter.put(DATABASE, tableArray[0]);
metricInputParameter.put(TABLE, tableArray[1]);
String connectorSchema = connectorParameter.getParameters().get(SCHEMA) != null ?
(String)connectorParameter.getParameters().get(SCHEMA) : null;
if (connectorSchema != null && connectorSchema.equals(tableArray[0])) {
// When the table name from SQL already includes the schema prefix
// (e.g., "schema.table"), and it matches the configured schema,
// treat it as schema.table, not database.table
metricInputParameter.put(TABLE, tableArray[1]);
} else {
metricInputParameter.put(DATABASE, tableArray[0]);
metricInputParameter.put(TABLE, tableArray[1]);
}
}

SourceConfig sourceConfig = new SourceConfig();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,12 @@ public Dataset<Row> getData(SparkRuntimeEnvironment env) {
}

DataFrameReader reader = new DataFrameReader(env.sparkSession());
return reader.jdbc(config.getString(URL), config.getString(TABLE), properties);
String table = config.getString(TABLE);
String schema = config.getString(SCHEMA);
if (!StringUtils.isEmptyOrNullStr(schema)) {
table = schema + "." + table;
}
return reader.jdbc(config.getString(URL), table, properties);
}

private Dataset<Row> hiveSourceData(SparkRuntimeEnvironment env) {
Expand Down
Loading