forked from apache/beam
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
258 additions
and
1 deletion.
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,42 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* License); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an AS IS BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
apply from: project(":").file("build_rules.gradle") | ||
applyJavaNature(failOnWarning: true, enableSpotless: true, testShadowJar: true, shadowClosure: {}) | ||
|
||
dependencies { | ||
compile project(path: ":beam-sdks-java-extensions-sql", configuration: "shadow") | ||
compile "jline:jline:2.14.6" | ||
compile "sqlline:sqlline:1.3.0" | ||
compile library.java.slf4j_jdk14 | ||
compileOnly library.java.findbugs_annotations | ||
testCompileOnly library.java.findbugs_annotations | ||
} | ||
|
||
shadowJar { | ||
manifest { | ||
attributes "Main-Class": "org.apache.beam.sdk.extensions.sql.jdbc.BeamSqlLine" | ||
} | ||
} | ||
|
||
test { | ||
doFirst { | ||
// Assert everything is in the output or test jar | ||
assert classpath.size() == 2 | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...xtensions/sql/jdbc/src/main/java/org/apache/beam/sdk/extensions/sql/jdbc/BeamSqlLine.java
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,35 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.beam.sdk.extensions.sql.jdbc; | ||
|
||
import static org.apache.beam.sdk.extensions.sql.impl.JdbcDriver.CONNECT_STRING_PREFIX; | ||
|
||
import java.io.IOException; | ||
import sqlline.SqlLine; | ||
|
||
/** {@link BeamSqlLine} provides default arguments to SqlLine. */ | ||
public class BeamSqlLine { | ||
public static void main(String[] args) throws IOException { | ||
String[] args2 = new String[2 + args.length]; | ||
args2[0] = "-u"; | ||
args2[1] = CONNECT_STRING_PREFIX; | ||
System.arraycopy(args, 0, args2, 2, args.length); | ||
|
||
SqlLine.main(args2); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...tensions/sql/jdbc/src/main/java/org/apache/beam/sdk/extensions/sql/jdbc/package-info.java
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,20 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/** Provides default commandline for sqlline. */ | ||
package org.apache.beam.sdk.extensions.sql.jdbc; |
55 changes: 55 additions & 0 deletions
55
...sions/sql/jdbc/src/test/java/org/apache/beam/sdk/extensions/sql/jdbc/BeamSqlLineTest.java
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,55 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.beam.sdk.extensions.sql.jdbc; | ||
|
||
import org.junit.Test; | ||
|
||
/** | ||
* Test for {@link org.apache.beam.sdk.extensions.sql.jdbc.BeamSqlLine}. Note that this test only | ||
* tests for crashes (due to ClassNotFoundException for example). It does not test output. | ||
*/ | ||
public class BeamSqlLineTest { | ||
|
||
@Test | ||
public void testSqlLine_emptyArgs() throws Exception { | ||
BeamSqlLine.main(new String[] {}); | ||
} | ||
|
||
@Test | ||
public void testSqlLine_nullCommand() throws Exception { | ||
BeamSqlLine.main(new String[] {"-e", ""}); | ||
} | ||
|
||
@Test | ||
public void testSqlLine_simple() throws Exception { | ||
BeamSqlLine.main(new String[] {"-e", "SELECT 1;"}); | ||
} | ||
|
||
@Test | ||
public void testSqlLine_parse() throws Exception { | ||
BeamSqlLine.main(new String[] {"-e", "SELECT 'beam';"}); | ||
} | ||
|
||
@Test | ||
public void testSqlLine_ddl() throws Exception { | ||
BeamSqlLine.main( | ||
new String[] { | ||
"-e", "CREATE TABLE test (id INTEGER) TYPE 'text';", "-e", "DROP TABLE test;" | ||
}); | ||
} | ||
} |
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