Skip to content

Commit 6bed69f

Browse files
authored
Merge branch 'apache:master' into HIVE-28655-part2
2 parents 5de4cd0 + 9e7f289 commit 6bed69f

File tree

624 files changed

+343500
-5207
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

624 files changed

+343500
-5207
lines changed

.github/workflows/docker-GA-images.yml

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,30 @@ jobs:
4343
if: github.event_name == 'workflow_dispatch' || github.event_name == 'create' && github.event.ref_type == 'tag' && startsWith(github.event.ref, 'rel/')
4444
runs-on: ubuntu-latest
4545
steps:
46+
- name: Free disk space
47+
run: |
48+
echo '===== Before ====='
49+
df -h
50+
sudo rm -rf /opt/hostedtoolcache/go
51+
sudo rm -rf /opt/hostedtoolcache/CodeQL
52+
sudo rm -rf /usr/lib/google-cloud-sdk
53+
sudo rm -rf /usr/local/julia*
54+
sudo rm -rf /usr/local/.ghcup
55+
sudo rm -rf /usr/share/swift
56+
sudo rm -rf /usr/share/dotnet
57+
sudo apt-get clean
58+
echo '===== After ====='
59+
df -h
60+
4661
- name: Checkout
4762
uses: actions/checkout@v3
4863

4964
- name: 'Set up JDK 21'
50-
uses: actions/setup-java@v1
65+
uses: actions/setup-java@v5
5166
with:
52-
java-version: 21
67+
java-version: '21'
68+
distribution: temurin
69+
cache: maven
5370

5471
- name: Prepare environment variables for Workflow Dispatch
5572
if: github.event_name == 'workflow_dispatch'
@@ -75,7 +92,7 @@ jobs:
7592
- name: Build Hive project
7693
if: github.event_name == 'create' && github.event.ref_type == 'tag' && startsWith(github.event.ref, 'rel/')
7794
run: |
78-
mvn clean package -DskipTests -Pdist
95+
mvn --batch-mode clean package -DskipTests -Pdist
7996
ls ./packaging/target/
8097
mv ./packaging/target/apache-hive-*-bin.tar.gz ./packaging/src/docker/
8198
rm -rf ./packaging/target
@@ -123,3 +140,9 @@ jobs:
123140
HIVE_VERSION=${{ env.HIVE_VERSION }}
124141
HADOOP_VERSION=${{ env.HADOOP_VERSION }}
125142
BUILD_ENV=${{ env.BUILD_ENV }}
143+
144+
- name: Dump disk usage on failure
145+
if: failure()
146+
run: |
147+
df -h
148+
du -xh / --max-depth=3 2>/dev/null | sort -h | tail -50

beeline/src/java/org/apache/hive/beeline/BeeLine.java

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@
7171
import java.util.ResourceBundle;
7272
import java.util.ServiceLoader;
7373
import java.util.Set;
74-
import java.util.SortedSet;
7574
import java.util.StringTokenizer;
7675
import java.util.TreeMap;
7776
import java.util.TreeSet;
@@ -310,12 +309,6 @@ public class BeeLine implements Closeable {
310309

311310
private final Completer beeLineCommandCompleter = new BeeLineCommandCompleter(Arrays.asList(commandHandlers));
312311

313-
static final SortedSet<String> KNOWN_DRIVERS = new TreeSet<String>(Arrays.asList(
314-
new String[] {
315-
"org.apache.hive.jdbc.HiveDriver",
316-
"org.apache.hadoop.hive.jdbc.HiveDriver",
317-
}));
318-
319312
static {
320313
try {
321314
Class.forName("org.jline.reader.LineReader");
@@ -2370,23 +2363,17 @@ private Driver findRegisteredDriver(String url) {
23702363
return null;
23712364
}
23722365

2373-
public Driver findLocalDriver(String url) throws Exception {
2366+
public Driver findLocalDriver(String url) throws SQLException {
23742367
Objects.requireNonNull(url);
23752368

23762369
Collection<Driver> currentDrivers = drivers == null ? Collections.emptyList() : drivers;
2377-
for (Driver d : currentDrivers) {
2378-
try {
2379-
String clazzName = d.getClass().getName();
2380-
Driver driver = (Driver) Class.forName(clazzName, true,
2381-
Thread.currentThread().getContextClassLoader()).newInstance();
2382-
if (driver.acceptsURL(url) && isSupportedLocalDriver(driver)) {
2383-
return driver;
2384-
}
2385-
} catch (SQLException e) {
2386-
throw e;
2370+
for (Driver driver : currentDrivers) {
2371+
// The 'driver' is already an instance from the ServiceLoader.
2372+
// We can use it directly without creating a new one via reflection.
2373+
if (driver.acceptsURL(url) && isSupportedLocalDriver(driver)) {
2374+
return driver;
23872375
}
23882376
}
2389-
23902377
return null;
23912378
}
23922379

beeline/src/java/org/apache/hive/beeline/Commands.java

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import java.sql.Statement;
4545
import java.util.ArrayList;
4646
import java.util.Arrays;
47+
import java.util.Comparator;
4748
import java.util.HashMap;
4849
import java.util.Iterator;
4950
import java.util.LinkedList;
@@ -340,48 +341,48 @@ public boolean reconnect(String line) {
340341
return true;
341342
}
342343

343-
344344
public boolean scan(String line) throws IOException {
345-
TreeSet<String> names = new TreeSet<String>();
346-
347345
if (beeLine.getDrivers() == null) {
348346
beeLine.setDrivers(beeLine.scanDrivers());
349347
}
350348

351-
beeLine.info(beeLine.loc("drivers-found-count", beeLine.getDrivers().size()));
349+
// Use a TreeSet to get a unique, sorted list of drivers by class name.
350+
Set<Driver> drivers =
351+
new TreeSet<>(Comparator.comparing(d -> d.getClass().getName()));
352+
drivers.addAll(beeLine.getDrivers());
352353

353-
// unique the list
354-
for (Iterator<Driver> i = beeLine.getDrivers().iterator(); i.hasNext();) {
355-
names.add(i.next().getClass().getName());
356-
}
354+
// Get count of the unique driver in classpath
355+
beeLine.info(beeLine.loc("drivers-found-count", drivers.size()));
357356

358-
beeLine.output(beeLine.getColorBuffer()
359-
.bold(beeLine.getColorBuffer().pad(beeLine.loc("compliant"), 10).getMono())
360-
.bold(beeLine.getColorBuffer().pad(beeLine.loc("jdbc-version"), 8).getMono())
361-
.bold(beeLine.getColorBuffer(beeLine.loc("driver-class")).getMono()));
357+
beeLine.output(
358+
beeLine
359+
.getColorBuffer()
360+
.bold(beeLine.getColorBuffer().pad(beeLine.loc("compliant"), 10).getMono())
361+
.bold(beeLine.getColorBuffer().pad(beeLine.loc("jdbc-version"), 8).getMono())
362+
.bold(beeLine.getColorBuffer(beeLine.loc("driver-class")).getMono()));
362363

363-
for (Iterator<String> i = names.iterator(); i.hasNext();) {
364-
String name = i.next().toString();
364+
for (Driver driver : drivers) {
365+
String name = driver.getClass().getName();
365366
try {
366-
Driver driver = (Driver) Class.forName(name).newInstance();
367-
ColorBuffer msg = beeLine.getColorBuffer()
368-
.pad(driver.jdbcCompliant() ? "yes" : "no", 10)
369-
.pad(driver.getMajorVersion() + "."
370-
+ driver.getMinorVersion(), 8)
371-
.append(name);
367+
// Use the driver instance that ServiceLoader already created for us.
368+
ColorBuffer msg =
369+
beeLine
370+
.getColorBuffer()
371+
.pad(driver.jdbcCompliant() ? "yes" : "no", 10)
372+
.pad(driver.getMajorVersion() + "." + driver.getMinorVersion(), 8)
373+
.append(name);
372374
if (driver.jdbcCompliant()) {
373375
beeLine.output(msg);
374376
} else {
375377
beeLine.output(beeLine.getColorBuffer().red(msg.getMono()));
376378
}
377379
} catch (Throwable t) {
378-
beeLine.output(beeLine.getColorBuffer().red(name)); // error with driver
380+
beeLine.error("Error processing driver " + name);
379381
}
380382
}
381383
return true;
382384
}
383385

384-
385386
public boolean save(String line) throws IOException {
386387
beeLine.info(beeLine.loc("saving-options", beeLine.getOpts().getPropertiesFile()));
387388
beeLine.getOpts().save();
@@ -1670,7 +1671,7 @@ public boolean connect(Properties props) throws IOException {
16701671

16711672
try {
16721673
beeLine.getDatabaseConnections().setConnection(
1673-
new DatabaseConnection(beeLine, driver, url, props));
1674+
new DatabaseConnection(beeLine, url, props));
16741675
beeLine.getDatabaseConnection().getConnection();
16751676

16761677
if (!beeLine.isBeeLine()) {

beeline/src/java/org/apache/hive/beeline/DatabaseConnection.java

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ class DatabaseConnection {
4949
private final BeeLine beeLine;
5050
private Connection connection;
5151
private DatabaseMetaData meta;
52-
private final String driver;
5352
private final String url;
5453
private final Properties info;
5554
private Schema schema = null;
@@ -59,10 +58,8 @@ public boolean isClosed() {
5958
return (null == connection);
6059
}
6160

62-
public DatabaseConnection(BeeLine beeLine, String driver, String url,
63-
Properties info) throws SQLException {
61+
DatabaseConnection(BeeLine beeLine, String url, Properties info) {
6462
this.beeLine = beeLine;
65-
this.driver = driver;
6663
this.url = url;
6764
this.info = info;
6865
}
@@ -85,14 +82,6 @@ void setCompletions(boolean skipmeta) throws SQLException, IOException {
8582
* Connection to the specified data source.
8683
*/
8784
boolean connect() throws SQLException {
88-
try {
89-
if (driver != null && driver.length() != 0) {
90-
Class.forName(driver);
91-
}
92-
} catch (ClassNotFoundException cnfe) {
93-
return beeLine.error(cnfe);
94-
}
95-
9685
boolean isDriverRegistered = false;
9786
try {
9887
isDriverRegistered = DriverManager.getDriver(getUrl()) != null;
@@ -163,18 +152,19 @@ boolean connect() throws SQLException {
163152

164153
public Connection getConnectionFromLocalDriver(String url, Properties properties) {
165154
Collection<Driver> drivers = beeLine.getDrivers();
166-
for (Driver d : drivers) {
155+
for (Driver driver : drivers) {
167156
try {
168-
if (d.acceptsURL(url) && beeLine.isSupportedLocalDriver(d)) {
169-
String clazzName = d.getClass().getName();
170-
beeLine.debug("Driver name is " + clazzName);
171-
Driver driver =
172-
(Driver) Class.forName(clazzName, true, Thread.currentThread().getContextClassLoader())
173-
.newInstance();
157+
if (driver.acceptsURL(url) && beeLine.isSupportedLocalDriver(driver)) {
158+
beeLine.debug("Driver name is " + driver.getClass().getName());
159+
// The 'driver' is already an instance from the ServiceLoader, so we can use it directly.
174160
return driver.connect(url, properties);
175161
}
176-
} catch (Exception e) {
177-
beeLine.error("Fail to connect with a local driver due to the exception:" + e);
162+
} catch (SQLException e) {
163+
beeLine.error(
164+
"Failed to connect with local driver "
165+
+ driver.getClass().getName()
166+
+ " due to exception: "
167+
+ e);
178168
beeLine.error(e);
179169
}
180170
}

beeline/src/test/org/apache/hive/beeline/ProxyAuthTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
* <HS2host> <HS2Port> <HS2-Server-principal> <client-principal>
4545
*/
4646
public class ProxyAuthTest {
47-
private static final String driverName = "org.apache.hive.jdbc.HiveDriver";
4847
private static final String BEELINE_EXIT = "beeline.system.exit";
4948
private static Connection con = null;
5049
private static boolean noClose = false;
@@ -68,7 +67,6 @@ public static void main(String[] args) throws Exception {
6867
File currentResultFile = null;
6968
String [] beeLineArgs = {};
7069

71-
Class.forName(driverName);
7270
String host = args[0];
7371
String port = args[1];
7472
String serverPrincipal = args[2];

beeline/src/test/org/apache/hive/beeline/TestShutdownHook.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ public void testShutdownHook() throws Exception {
3030
PrintStream ops = new PrintStream(os);
3131
BeeLine beeline = new BeeLine();
3232
DatabaseConnections dbConnections = beeline.getDatabaseConnections();
33-
dbConnections.setConnection(new DatabaseConnection(beeline,null,null, null));
34-
dbConnections.setConnection(new DatabaseConnection(beeline,null,null, null));
33+
dbConnections.setConnection(new DatabaseConnection(beeline, null, null));
34+
dbConnections.setConnection(new DatabaseConnection(beeline, null, null));
3535
Assert.assertEquals(2, dbConnections.size());
3636
beeline.setOutputStream(ops);
3737
beeline.getShutdownHook().run();
3838
Assert.assertEquals(0, dbConnections.size());
3939
}
40-
}
40+
}

bin/hive

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ bin=`cd "$bin"; pwd`
2828
SERVICE=""
2929
HELP=""
3030
SKIP_HBASECP=false
31-
SKIP_HADOOPVERSION=false
3231
EXECUTE_WITH_JAVA=false
3332

3433
SERVICE_ARGS=()
@@ -60,7 +59,6 @@ while [ $# -gt 0 ]; do
6059
shift
6160
;;
6261
--skiphadoopversion)
63-
SKIP_HADOOPVERSION=true
6462
shift
6563
;;
6664
--skiphbasecp)
@@ -105,10 +103,6 @@ if [[ "$SERVICE" =~ ^(help|version|orcfiledump|rcfilecat|schemaTool|cleardanglin
105103
SKIP_HBASECP=true
106104
fi
107105

108-
if [[ "$SERVICE" =~ ^(help|schemaTool)$ ]] ; then
109-
SKIP_HADOOPVERSION=true
110-
fi
111-
112106
if [ -f "${HIVE_CONF_DIR}/hive-env.sh" ]; then
113107
. "${HIVE_CONF_DIR}/hive-env.sh"
114108
fi
@@ -298,37 +292,6 @@ if [ ! -f ${HADOOP} ]; then
298292
fi
299293
fi
300294

301-
if [ "$EXECUTE_WITH_JAVA" == "false" ]; then
302-
if [ "$SKIP_HADOOPVERSION" = false ]; then
303-
# Make sure we're using a compatible version of Hadoop
304-
if [ "x$HADOOP_VERSION" == "x" ]; then
305-
HADOOP_VERSION=$($HADOOP version 2>&2 | awk -F"\t" '/Hadoop/ {print $0}' | cut -d' ' -f 2);
306-
fi
307-
308-
# Save the regex to a var to workaround quoting incompatabilities
309-
# between Bash 3.1 and 3.2
310-
hadoop_version_re="^([[:digit:]]+)\.([[:digit:]]+)(\.([[:digit:]]+))?.*$"
311-
312-
if [[ "$HADOOP_VERSION" =~ $hadoop_version_re ]]; then
313-
hadoop_major_ver=${BASH_REMATCH[1]}
314-
hadoop_minor_ver=${BASH_REMATCH[2]}
315-
hadoop_patch_ver=${BASH_REMATCH[4]}
316-
else
317-
echo "Unable to determine Hadoop version information."
318-
echo "'hadoop version' returned:"
319-
echo `$HADOOP version`
320-
exit 5
321-
fi
322-
323-
if [ "$hadoop_major_ver" -lt "1" -a "$hadoop_minor_ver$hadoop_patch_ver" -lt "201" ]; then
324-
echo "Hive requires Hadoop 0.20.x (x >= 1)."
325-
echo "'hadoop version' returned:"
326-
echo `$HADOOP version`
327-
exit 6
328-
fi
329-
fi
330-
fi
331-
332295
if [ "${AUX_PARAM}" != "" ]; then
333296
if [[ "$SERVICE" != beeline ]]; then
334297
HIVE_OPTS="$HIVE_OPTS --hiveconf hive.aux.jars.path=${AUX_PARAM}"

common/pom.xml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -414,18 +414,6 @@
414414
</testResource>
415415
</testResources>
416416
<plugins>
417-
<plugin>
418-
<groupId>org.apache.maven.plugins</groupId>
419-
<artifactId>maven-compiler-plugin</artifactId>
420-
<configuration>
421-
<compilerArgs>
422-
<arg>--add-opens</arg>
423-
<arg>org.apache.hadoop/org.apache.hadoop.fs=ALL-UNNAMED</arg>
424-
<arg>--add-opens</arg>
425-
<arg>java.base/java.net=ALL-UNNAMED</arg>
426-
</compilerArgs>
427-
</configuration>
428-
</plugin>
429417
<plugin>
430418
<groupId>org.apache.maven.plugins</groupId>
431419
<artifactId>maven-antrun-plugin</artifactId>

0 commit comments

Comments
 (0)