Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add partition config for maxcompute #25

Merged
merged 1 commit into from
Nov 18, 2021
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
2 changes: 2 additions & 0 deletions nebula-exchange/src/main/resources/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,8 @@
accessKeyId:xxx
accessKeySecret:xxx
partitionSpec:"dt='partition1'"
# default numPartitions is 1
numPartitions:100
# maxcompute sql sentence only uses table name. make sure that table name is the same with {table}'s value'.
sentence:"select id, maxcompute-field-0, maxcompute-field-1, maxcompute-field-2 from table where id < 10"
fields:[maxcompute-field-0, maxcompute-field-1]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,11 @@ object Configs {
} else {
null
}
val numPartitions = if (config.hasPath("numPartitions")) {
config.getString("numPartitions")
} else {
"1"
}

val sentence = if (config.hasPath("sentence")) {
config.getString("sentence")
Expand All @@ -705,6 +710,7 @@ object Configs {
config.getString("accessKeyId"),
config.getString("accessKeySecret"),
partitionSpec,
numPartitions,
sentence
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ case class MaxComputeConfigEntry(override val category: SourceCategory.Value,
accessKeyId: String,
accessKeySecret: String,
partitionSpec: String,
numPartitions: String,
override val sentence: String)
extends ServerDataSourceConfigEntry {
require(
Expand All @@ -240,7 +241,7 @@ case class MaxComputeConfigEntry(override val category: SourceCategory.Value,
override def toString: String = {
s"MaxCompute source {odpsUrl: $odpsUrl, tunnelUrl: $tunnelUrl, table: $table, project: $project, " +
s"keyId: $accessKeyId, keySecret: $accessKeySecret, partitionSpec:$partitionSpec, " +
s"sentence:$sentence}"
s"numPartitions:$numPartitions, sentence:$sentence}"
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ class MaxcomputeReader(override val session: SparkSession, maxComputeConfig: Max
.option("project", maxComputeConfig.project)
.option("accessKeyId", maxComputeConfig.accessKeyId)
.option("accessKeySecret", maxComputeConfig.accessKeySecret)
.option("numPartitions", maxComputeConfig.numPartitions)

// if use partition read
if (maxComputeConfig.partitionSpec != null) {
Expand Down