Skip to content

Commit

Permalink
Merge branch 'apache:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
fanxishu authored Dec 15, 2024
2 parents f13236b + 0fb6a65 commit 64c8bb6
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
package org.apache.seatunnel.datasource.plugin.oracle.jdbc;

import org.apache.seatunnel.api.configuration.util.OptionRule;
import org.apache.seatunnel.common.utils.SeaTunnelException;
import org.apache.seatunnel.datasource.plugin.api.DataSourceChannel;
import org.apache.seatunnel.datasource.plugin.api.DataSourcePluginException;
import org.apache.seatunnel.datasource.plugin.api.model.TableField;
import org.apache.seatunnel.datasource.plugin.api.utils.JdbcUtils;

import org.apache.commons.lang3.StringUtils;

Expand Down Expand Up @@ -170,10 +170,19 @@ public List<TableField> getTableFields(
@NonNull String database,
@NonNull String table) {
List<TableField> tableFields = new ArrayList<>();
try (Connection connection = getConnection(requestParams, database)) {
try (Connection connection = getConnection(requestParams)) {
DatabaseMetaData metaData = connection.getMetaData();
String primaryKey = getPrimaryKey(metaData, database, table);
try (ResultSet resultSet = metaData.getColumns(database, null, table, null)) {
String[] split = table.split("\\.");
if (split.length != 2) {
throw new SeaTunnelException(
"The tableName for oracle must be schemaName.tableName, but tableName is "
+ table);
}

String schemaName = split[0];
String tableName = split[1];
try (ResultSet resultSet = metaData.getColumns(database, schemaName, tableName, null)) {
while (resultSet.next()) {
TableField tableField = new TableField();
String columnName = resultSet.getString("COLUMN_NAME");
Expand Down Expand Up @@ -215,16 +224,9 @@ private String getPrimaryKey(DatabaseMetaData metaData, String dbName, String ta

private Connection getConnection(Map<String, String> requestParams)
throws SQLException, ClassNotFoundException {
return getConnection(requestParams, null);
}

private Connection getConnection(Map<String, String> requestParams, String databaseName)
throws SQLException, ClassNotFoundException {
checkNotNull(requestParams.get(OracleOptionRule.DRIVER.key()));
checkNotNull(requestParams.get(OracleOptionRule.URL.key()), "Jdbc url cannot be null");
String url =
JdbcUtils.replaceDatabase(
requestParams.get(OracleOptionRule.URL.key()), databaseName);
String url = requestParams.get(OracleOptionRule.URL.key());
if (requestParams.containsKey(OracleOptionRule.USER.key())) {
String username = requestParams.get(OracleOptionRule.USER.key());
String password = requestParams.get(OracleOptionRule.PASSWORD.key());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ check() {

# start
start() {
echo "starting seatunnel..."
echo "starting seatunnel-web..."

check

Expand All @@ -58,27 +58,27 @@ start() {
-cp "$WORKDIR/../conf":"$WORKDIR/../libs/*":"$WORKDIR/../datasource/*" \
$SPRING_OPTS \
org.apache.seatunnel.app.SeatunnelApplication >> "${LOGDIR}/seatunnel.out" 2>&1 &
echo "seatunnel started"
echo "seatunnel-web started"
}
# stop
stop() {
echo "stopping seatunnel..."
echo "stopping seatunnel-web..."
pid=$(jcmd | grep -i 'org.apache.seatunnel.app.SeatunnelApplication' | grep -v grep | awk '{print $1}')
if [ -n "$pid" ]; then
kill -15 $pid
echo "seatunnel stopped"
echo "seatunnel-web stopped"
else
echo "seatunnel is not running"
echo "seatunnel-web is not running"
fi
}

#status
status() {
pid=$(jcmd | grep -i 'seatunnel-app-.*jar' | grep -v grep | awk '{print $1}')
pid=$(jcmd | grep -i 'org.apache.seatunnel.app.SeatunnelApplication' | grep -v grep | awk '{print $1}')
if [ -n "$pid" ]; then
echo "seatunnel is running"
echo "seatunnel-web is running"
else
echo "seatunnel is not running"
echo "seatunnel-web is not running"
fi
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ public abstract class BaseJdbcDataSourceConfigSwitcher extends AbstractDataSourc
private static final String BASE_URL = "base-url";
private static final String CATALOG_SCHEMA = "schema";

private static final String WHERE_CONDITION = "where_condition";

private static final Option<String> DATABASE_SCHEMA =
Options.key("database_schema")
.stringType()
Expand Down Expand Up @@ -137,6 +139,13 @@ public Config mergeDatasourceConfig(
List<String> tableFields = selectTableFields.getTableFields();

String sql = tableFieldsToSql(tableFields, databaseName, tableName);
if (connectorConfig.hasPath(WHERE_CONDITION)) {
String where_condition = connectorConfig.getString(WHERE_CONDITION);
if (where_condition != null && !where_condition.isEmpty()) {
sql = sql + " " + where_condition;
connectorConfig = connectorConfig.withoutPath(WHERE_CONDITION);
}
}

connectorConfig =
connectorConfig.withValue(QUERY_KEY, ConfigValueFactory.fromAnyRef(sql));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const DagSidebar = defineComponent({
class="task-item-info ml-auto inline-block"
title={'Drag Source into Canvas and Double Click to Setup Configurations'}
>
<InfoCircleOutlined width="17px" height="17px" />
<InfoCircleOutlined style={{width:'17px', height:'17px'}} />
</span>
</div>
<div
Expand All @@ -88,7 +88,7 @@ const DagSidebar = defineComponent({
class="task-item-info ml-auto inline-block"
title={'Drag Sink into Canvas and Double Click to Setup Configurations'}
>
<InfoCircleOutlined width="17px" height="17px" />
<InfoCircleOutlined style={{width:'17px', height:'17px'}} />
</span>
</div>
{this.transforms.length > 0 && (
Expand Down Expand Up @@ -133,7 +133,7 @@ const DagSidebar = defineComponent({
class="task-item-info ml-auto inline-block"
title={'Drag '+ item.name +' into Canvas and Double Click to Setup Configurations'}
>
<InfoCircleOutlined width="17px" height="17px" />
<InfoCircleOutlined style={{width:'17px', height:'17px'}} />
</span>
</div>
)
Expand Down

0 comments on commit 64c8bb6

Please sign in to comment.