Skip to content

Commit b304824

Browse files
committed
[SQL] Build mega jar for JDBC
1 parent a13dcb8 commit b304824

File tree

6 files changed

+258
-1
lines changed

6 files changed

+258
-1
lines changed

LICENSE

+104-1
Original file line numberDiff line numberDiff line change
@@ -298,4 +298,107 @@
298298
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
299299
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
300300
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
301-
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
301+
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
302+
303+
jline:
304+
Copyright (c) 2002-2016, the original author or authors.
305+
All rights reserved.
306+
307+
http://www.opensource.org/licenses/bsd-license.php
308+
309+
Redistribution and use in source and binary forms, with or
310+
without modification, are permitted provided that the following
311+
conditions are met:
312+
313+
Redistributions of source code must retain the above copyright
314+
notice, this list of conditions and the following disclaimer.
315+
316+
Redistributions in binary form must reproduce the above copyright
317+
notice, this list of conditions and the following disclaimer
318+
in the documentation and/or other materials provided with
319+
the distribution.
320+
321+
Neither the name of JLine nor the names of its contributors
322+
may be used to endorse or promote products derived from this
323+
software without specific prior written permission.
324+
325+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
326+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
327+
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
328+
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
329+
EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
330+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
331+
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
332+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
333+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
334+
AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
335+
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
336+
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
337+
OF THE POSSIBILITY OF SUCH DAMAGE.
338+
339+
sqlline:
340+
SQLLine - Shell for issuing SQL to relational databases via JDBC
341+
342+
Copyright (c) 2002,2003,2004,2005,2006,2007 Marc Prud'hommeaux
343+
Copyright (c) 2004-2010 The Eigenbase Project
344+
Copyright (c) 2013-2017 Julian Hyde
345+
All rights reserved.
346+
347+
===============================================================================
348+
349+
Licensed under the Modified BSD License (the "License"); you may not
350+
use this file except in compliance with the License. You may obtain a
351+
copy of the License at:
352+
353+
http://opensource.org/licenses/BSD-3-Clause
354+
355+
Redistribution and use in source and binary forms,
356+
with or without modification, are permitted provided
357+
that the following conditions are met:
358+
359+
(1) Redistributions of source code must retain the above copyright
360+
notice, this list of conditions and the following disclaimer.
361+
362+
(2) Redistributions in binary form must reproduce the above copyright
363+
notice, this list of conditions and the following disclaimer in the
364+
documentation and/or other materials provided with the
365+
distribution.
366+
367+
(3) The name of the author may not be used to endorse or promote
368+
products derived from this software without specific prior written
369+
permission.
370+
371+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
372+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
373+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
374+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
375+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
376+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
377+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
378+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
379+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
380+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
381+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
382+
383+
slf4j:
384+
Copyright (c) 2004-2017 QOS.ch
385+
All rights reserved.
386+
387+
Permission is hereby granted, free of charge, to any person obtaining
388+
a copy of this software and associated documentation files (the
389+
"Software"), to deal in the Software without restriction, including
390+
without limitation the rights to use, copy, modify, merge, publish,
391+
distribute, sublicense, and/or sell copies of the Software, and to
392+
permit persons to whom the Software is furnished to do so, subject to
393+
the following conditions:
394+
395+
The above copyright notice and this permission notice shall be
396+
included in all copies or substantial portions of the Software.
397+
398+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
399+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
400+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
401+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
402+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
403+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
404+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* License); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an AS IS BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
apply from: project(":").file("build_rules.gradle")
20+
applyJavaNature(failOnWarning: true, enableSpotless: true, testShadowJar: true, shadowClosure: {})
21+
22+
dependencies {
23+
compile project(path: ":beam-sdks-java-extensions-sql", configuration: "shadow")
24+
compile "jline:jline:2.14.6"
25+
compile "sqlline:sqlline:1.3.0"
26+
compile library.java.slf4j_jdk14
27+
compileOnly library.java.findbugs_annotations
28+
testCompileOnly library.java.findbugs_annotations
29+
}
30+
31+
shadowJar {
32+
manifest {
33+
attributes "Main-Class": "org.apache.beam.sdk.extensions.sql.jdbc.BeamSqlLine"
34+
}
35+
}
36+
37+
test {
38+
doFirst {
39+
// Assert everything is in the output or test jar
40+
assert classpath.size() == 2
41+
}
42+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
package org.apache.beam.sdk.extensions.sql.jdbc;
19+
20+
import static org.apache.beam.sdk.extensions.sql.impl.JdbcDriver.CONNECT_STRING_PREFIX;
21+
22+
import java.io.IOException;
23+
import sqlline.SqlLine;
24+
25+
/** {@link BeamSqlLine} provides default arguments to SqlLine. */
26+
public class BeamSqlLine {
27+
public static void main(String[] args) throws IOException {
28+
String[] args2 = new String[2 + args.length];
29+
args2[0] = "-u";
30+
args2[1] = CONNECT_STRING_PREFIX;
31+
System.arraycopy(args, 0, args2, 2, args.length);
32+
33+
SqlLine.main(args2);
34+
}
35+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
/** Provides default commandline for sqlline. */
20+
package org.apache.beam.sdk.extensions.sql.jdbc;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
package org.apache.beam.sdk.extensions.sql.jdbc;
19+
20+
import org.junit.Test;
21+
22+
/**
23+
* Test for {@link org.apache.beam.sdk.extensions.sql.jdbc.BeamSqlLine}. Note that this test only
24+
* tests for crashes (due to ClassNotFoundException for example). It does not test output.
25+
*/
26+
public class BeamSqlLineTest {
27+
28+
@Test
29+
public void testSqlLine_emptyArgs() throws Exception {
30+
BeamSqlLine.main(new String[] {});
31+
}
32+
33+
@Test
34+
public void testSqlLine_nullCommand() throws Exception {
35+
BeamSqlLine.main(new String[] {"-e", ""});
36+
}
37+
38+
@Test
39+
public void testSqlLine_simple() throws Exception {
40+
BeamSqlLine.main(new String[] {"-e", "SELECT 1;"});
41+
}
42+
43+
@Test
44+
public void testSqlLine_parse() throws Exception {
45+
BeamSqlLine.main(new String[] {"-e", "SELECT 'beam';"});
46+
}
47+
48+
@Test
49+
public void testSqlLine_ddl() throws Exception {
50+
BeamSqlLine.main(
51+
new String[] {
52+
"-e", "CREATE TABLE test (id INTEGER) TYPE 'text';", "-e", "DROP TABLE test;"
53+
});
54+
}
55+
}

settings.gradle

+2
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ include "beam-sdks-java-extensions-sorter"
8484
project(":beam-sdks-java-extensions-sorter").dir = file("sdks/java/extensions/sorter")
8585
include "beam-sdks-java-extensions-sql"
8686
project(":beam-sdks-java-extensions-sql").dir = file("sdks/java/extensions/sql")
87+
include "beam-sdks-java-extensions-sql-jdbc"
88+
project(":beam-sdks-java-extensions-sql-jdbc").dir = file("sdks/java/extensions/sql/jdbc")
8789
include "beam-sdks-java-fn-execution"
8890
project(":beam-sdks-java-fn-execution").dir = file("sdks/java/fn-execution")
8991
include "beam-sdks-java-harness"

0 commit comments

Comments
 (0)