-
Notifications
You must be signed in to change notification settings - Fork 141
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 JDBC datasource #1361
Closed
Closed
Add JDBC datasource #1361
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
d521515
Resolve table function based StorageEngine provided function resolver
penghuo 0e1ba39
jdbc ut passed
penghuo 25efd3d
add jdbc
penghuo 831a27f
add doctest
penghuo bce2fbd
fix UT
penghuo a66c380
upgrade thrift version
penghuo 227e4f1
Merge branch 'main' into pr/spark/jdbc
penghuo 247de89
update
penghuo a4faff8
fix depedency issue
penghuo c244f85
Merge branch 'main' into pr/spark/jdbc
penghuo 0ecb5dd
update vulnerable library
penghuo a0343ae
update codec version
penghuo 5f2d6ba
update doc
penghuo 2085f8e
update doc
penghuo 1a643ae
address comments
penghuo 4c95018
fix UT
penghuo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
.. highlight:: sh | ||
|
||
============== | ||
JDBC Connector | ||
============== | ||
|
||
.. rubric:: Table of contents | ||
|
||
.. contents:: | ||
:local: | ||
:depth: 1 | ||
|
||
|
||
Introduction | ||
============ | ||
|
||
This page covers JDBC connector properties for dataSource configuration and the nuances associated with JDBC connector. | ||
|
||
|
||
JDBC Connector Properties in DataSource Configuration | ||
===================================================== | ||
JDBC Connector Properties. | ||
|
||
* ``url`` [Required]. | ||
* This parameters provides the URL to connect to a database instance provided endpoint. | ||
* ``driver`` [Required]. | ||
* This parameters provides the Driver to connect to a database instance provided endpoint. Only support ``org.apache.hive.jdbc.HiveDriver`` | ||
* ``username`` [Optional]. | ||
* This username for basicauth. | ||
* ``password`` [Optional]. | ||
* This password for basicauth. | ||
|
||
Example dataSource configuration with basic authentications | ||
=========================================================== | ||
|
||
No Auth :: | ||
|
||
[{ | ||
"name" : "myspark", | ||
"connector": "jdbc", | ||
"properties" : { | ||
"url" : "jdbc:hive2://localhost:10000/default", | ||
"driver" : "org.apache.hive.jdbc.HiveDriver" | ||
} | ||
}] | ||
|
||
Basic Auth :: | ||
|
||
[{ | ||
"name" : "myspark", | ||
"connector": "jdbc", | ||
"properties" : { | ||
"url" : "jdbc:hive2://localhost:10000/default", | ||
"driver" : "org.apache.hive.jdbc.HiveDriver", | ||
"username" : "username", | ||
"password" : "password" | ||
} | ||
}] | ||
|
||
PPL supported for jdbc connector | ||
================================ | ||
|
||
JDBC Table Function | ||
------------------- | ||
JDBC datasource could execute direct SQL against the target database. The SQL must be supported by target database. | ||
|
||
Example:: | ||
|
||
os> source = myspark.jdbc('SHOW DATABASES'); | ||
fetched rows / total rows = 1/1 | ||
+-------------+ | ||
| namespace | | ||
|-------------| | ||
| default | | ||
+-------------+ | ||
|
||
Limitation | ||
================================ | ||
|
||
* PPL command other source is not supported. for example, if user use ``source = myspark.jdbc('SHOW DATABASES') | fields namespace``, query engine will throw exception. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
plugins { | ||
id 'java-library' | ||
id "io.freefair.lombok" | ||
id 'jacoco' | ||
id 'info.solidsoft.pitest' version '1.9.0' | ||
} | ||
|
||
dependencies { | ||
implementation project(':core') | ||
implementation project(':common') | ||
runtimeOnly('org.apache.hive:hive-jdbc:3.1.3') { | ||
exclude group: "org.apache.hadoop", module: "hadoop-common" | ||
exclude group: 'org.apache.zookeeper' | ||
exclude group: "org.apache.hive", module: "hive-metastore" | ||
exclude group: "org.apache.hive", module: "hive-shims" | ||
exclude group: 'org.apache.hive', module: 'hive-llap-server' | ||
exclude group: 'org.apache.hive', module: 'hive-upgrade-acid' | ||
|
||
// exclude for resolving version conflict | ||
exclude group: 'org.apache.httpcomponents', module: 'httpcore' | ||
exclude group: 'org.apache.httpcomponents', module: 'httpclient' | ||
|
||
// exclude for include with transitive = false | ||
exclude group: "org.apache.hive", module: "hive-common" | ||
exclude group: "org.apache.hive", module: "hive-service" | ||
exclude group: "org.apache.hive", module: "hive-serde" | ||
exclude group: 'org.apache.hive', module: 'hive-service-rpc' | ||
|
||
// exclude because of CVE-2019-0205 | ||
exclude group: 'org.apache.thrift', module: 'libthrift' | ||
} | ||
runtimeOnly('org.apache.httpcomponents:httpcore:4.4.12') | ||
runtimeOnly('org.apache.httpcomponents:httpclient:4.5.13') { | ||
exclude group: 'commons-codec', module: 'commons-codec' | ||
} | ||
runtimeOnly('org.apache.hive:hive-service:3.1.3') { | ||
transitive = false | ||
} | ||
runtimeOnly('org.apache.hive:hive-serde:3.1.3') { | ||
transitive = false | ||
} | ||
runtimeOnly('org.apache.hive:hive-common:3.1.3') { | ||
transitive = false | ||
} | ||
runtimeOnly('org.apache.hive:hive-service-rpc:3.1.3') { | ||
transitive = false | ||
} | ||
runtimeOnly('commons-codec:commons-codec:1.13') { | ||
transitive = false | ||
} | ||
runtimeOnly('org.apache.thrift:libthrift:0.18.1') | ||
runtimeOnly 'commons-lang:commons-lang:2.6' | ||
|
||
testImplementation('org.junit.jupiter:junit-jupiter:5.6.2') | ||
testImplementation group: 'org.hamcrest', name: 'hamcrest-library', version: '2.1' | ||
testImplementation group: 'org.mockito', name: 'mockito-core', version: '3.12.4' | ||
testImplementation group: 'org.mockito', name: 'mockito-junit-jupiter', version: '3.12.4' | ||
} | ||
|
||
pitest { | ||
targetClasses = ['org.opensearch.sql.*'] | ||
pitestVersion = '1.9.0' | ||
threads = 4 | ||
outputFormats = ['HTML', 'XML'] | ||
timestampedReports = false | ||
junit5PluginVersion = '1.0.0' | ||
} | ||
|
||
test { | ||
useJUnitPlatform() | ||
testLogging { | ||
events "skipped", "failed" | ||
exceptionFormat "full" | ||
} | ||
} | ||
|
||
jacocoTestReport { | ||
reports { | ||
html.enabled true | ||
xml.enabled true | ||
} | ||
afterEvaluate { | ||
classDirectories.setFrom(files(classDirectories.files.collect { | ||
fileTree(dir: it) | ||
})) | ||
} | ||
} | ||
test.finalizedBy(project.tasks.jacocoTestReport) | ||
|
||
jacocoTestCoverageVerification { | ||
violationRules { | ||
rule { | ||
element = 'CLASS' | ||
excludes = [ | ||
] | ||
limit { | ||
counter = 'LINE' | ||
minimum = 1.0 | ||
} | ||
limit { | ||
counter = 'BRANCH' | ||
minimum = 1.0 | ||
} | ||
} | ||
} | ||
afterEvaluate { | ||
classDirectories.setFrom(files(classDirectories.files.collect { | ||
fileTree(dir: it) | ||
})) | ||
} | ||
} | ||
check.dependsOn jacocoTestCoverageVerification | ||
jacocoTestCoverageVerification.dependsOn jacocoTestReport |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Is it cross-platform?
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.
To piggy-back on this, is it possible to run Spark in Docker?