-
Notifications
You must be signed in to change notification settings - Fork 68
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
Spark: Support read with settings #367
Spark: Support read with settings #367
Conversation
@@ -209,4 +209,13 @@ object ClickHouseSQLConf { | |||
.stringConf | |||
.transform(_.toLowerCase) | |||
.createWithDefault("binary") | |||
|
|||
val READ_WITH_SETTINGS: ConfigEntry[String] = | |||
buildConf("spark.clickhouse.read.withSettings") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
buildConf("spark.clickhouse.read.withSettings") | |
buildConf("spark.clickhouse.read.settings") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will also renaming the val to READ_SETTINGS
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
|
||
val READ_WITH_SETTINGS: ConfigEntry[String] = | ||
buildConf("spark.clickhouse.read.withSettings") | ||
.doc("Query-level settings when reading from ClickHouse. e.g. `final=1, max_execution_time=5`") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from the spark perspective, it's a session-level configuration
SET spark.clickhouse.read.settings=final=1;
SELECT * FROM ch.db.t1; -- affected
SELECT * FROM ch.db.t2; -- affected too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agree. will update the doc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
@@ -60,6 +61,7 @@ abstract class ClickHouseReader[Record]( | |||
|WHERE (${part.partFilterExpr}) AND (${scanJob.filtersExpr}) | |||
|${scanJob.groupByClause.getOrElse("")} | |||
|${scanJob.limit.map(n => s"LIMIT $n").getOrElse("")} | |||
|${if (readWithSettings.nonEmpty) s"SETTINGS $readWithSettings" else ""} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|${if (readWithSettings.nonEmpty) s"SETTINGS $readWithSettings" else ""} | |
|${readSettings.map(settings => s"SETTINGS $settings" else ""} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
.version("0.9.0") | ||
.stringConf | ||
.transform(_.toLowerCase) | ||
.createWithDefault("") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.createWithDefault("") | |
.createOptional |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will update it to OptionalConfigEntry
accordingly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@harryshi10 Can we provide tests of the new feature?
@pan3793, do you think we also need to provide |
.doc("Settings when read from ClickHouse. e.g. `final=1, max_execution_time=5`") | ||
.version("0.9.0") | ||
.stringConf | ||
.transform(_.toLowerCase) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why should convert the input to lower case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in case we'd like to log scanQuery which keeps SQL keywords in uppercase and other text in lowercase
code change lgtm, would be great if you could provide a test case |
yes, it could be implemented in another PR. Additionally, SPARK-36680 (Spark 4.0) provides a more intuitive SQL syntax for this case
|
sorry I'm still a rookie at Scala. but I will try to write a UT for this new feature |
@harryshi10 could please sign CLA |
done |
please refer to the error message to fix the docs, other lgtm |
doc updated to indicate the default value is None. sorry for missing of that and the delay of reply |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have we changed something in our tests?
@harryshi10 can you please sign the CLA |
Signed. Apologies, I just realized I used two different accounts to push this PR and signed with both. |
Summary
allow read with settings.
close #272