Skip to content

Commit

Permalink
beeline test pass
Browse files Browse the repository at this point in the history
  • Loading branch information
pan3793 committed Mar 6, 2024
1 parent 6150b13 commit 898a24e
Show file tree
Hide file tree
Showing 33 changed files with 249 additions and 2,489 deletions.
2 changes: 2 additions & 0 deletions .rat-excludes
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,5 @@ build/scala-*/**
**/node_modules/**
**/gen/*
**/*.tokens
**/BeeLine.properties
**/sql-keywords.properties
91 changes: 31 additions & 60 deletions kyuubi-hive-beeline/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,6 @@
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>org.apache.hive</groupId>
<artifactId>hive-beeline</artifactId>
<version>${hive.version}</version>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.apache.hive</groupId>
<artifactId>hive-common</artifactId>
Expand All @@ -71,44 +59,13 @@
</dependency>

<dependency>
<groupId>org.apache.hive</groupId>
<artifactId>hive-jdbc</artifactId>
<version>${hive.version}</version>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.apache.hive</groupId>
<artifactId>hive-service-rpc</artifactId>
<version>${hive.version}</version>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.apache.hive</groupId>
<artifactId>hive-service</artifactId>
<version>${hive.version}</version>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-client-api</artifactId>
</dependency>

<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-client-api</artifactId>
<artifactId>hadoop-client-runtime</artifactId>
</dependency>

<dependency>
Expand All @@ -121,12 +78,6 @@
<artifactId>commons-io</artifactId>
</dependency>

<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
Expand Down Expand Up @@ -182,14 +133,9 @@
</dependency>

<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-client-runtime</artifactId>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>

<dependency>
Expand Down Expand Up @@ -236,6 +182,31 @@
<skipTests>${skipTests}</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy</id>
<goals>
<goal>copy</goal>
</goals>
<phase>process-test-resources</phase>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>${postgresql.version}</version>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>

</plugins>
<outputDirectory>target/classes</outputDirectory>
<testOutputDirectory>target/test-classes</testOutputDirectory>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@
import org.apache.hive.beeline.hs2connection.HiveSiteHS2ConnectionFileParser;
import org.apache.hive.beeline.hs2connection.UserHS2ConnectionFileParser;
import org.apache.hive.common.util.ShutdownHookManager;
import org.apache.hive.jdbc.JdbcUriParseException;
import org.apache.hive.jdbc.Utils;
import org.apache.hive.jdbc.Utils.JdbcConnectionParams;
import org.apache.thrift.transport.TTransportException;
import org.apache.kyuubi.jdbc.hive.JdbcConnectionParams;
import org.apache.kyuubi.jdbc.hive.JdbcUriParseException;
import org.apache.kyuubi.jdbc.hive.Utils;
import org.apache.kyuubi.shaded.thrift.transport.TTransportException;

/**
* A console SQL shell with command completion.
Expand Down Expand Up @@ -453,8 +453,7 @@ String loc(String res) {
String loc(String res, int param) {
try {
return MessageFormat.format(
new ChoiceFormat(resourceBundle.getString(res)).format(param),
new Object[] {new Integer(param)});
new ChoiceFormat(resourceBundle.getString(res)).format(param), param);
} catch (Exception e) {
return res + ": " + param;
}
Expand Down Expand Up @@ -483,7 +482,7 @@ String loc(String res, Object[] params) {

protected String locElapsedTime(long milliseconds) {
if (getOpts().getShowElapsedTime()) {
return loc("time-ms", new Object[] {new Double(milliseconds / 1000d)});
return loc("time-ms", new Object[] {milliseconds / 1000d});
}
return "";
}
Expand Down Expand Up @@ -1177,12 +1176,9 @@ int runInit() {
return executionResult;
}

// TODO: remove embedded mode support
private int embeddedConnect() {
if (!execCommandWithPrefix("!connect " + Utils.URL_PREFIX + " '' ''")) {
return ERRNO_OTHER;
} else {
return ERRNO_OK;
}
return ERRNO_OTHER;
}

private int connectDBInEmbededMode() {
Expand Down Expand Up @@ -2032,7 +2028,7 @@ void handleSQLException(SQLException e) {
new Object[] {
e.getMessage() == null ? "" : e.getMessage().trim(),
e.getSQLState() == null ? "" : e.getSQLState().trim(),
new Integer(e.getErrorCode())
e.getErrorCode()
}));

if (getOpts().getVerbose()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static List<Completer> getCompleters(Iterable<CommandHandler> handlers) {
compl.add(new StringsCompleter(BeeLine.COMMAND_PREFIX + commandName));
compl.addAll(Arrays.asList(handler.getParameterCompleters()));
compl.add(new NullCompleter()); // last param no complete
completers.add(new AggregateCompleter(compl.toArray(new Completer[compl.size()])));
completers.add(new AggregateCompleter(compl.toArray(new Completer[0])));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@

/** BeeLineSignalHandler. */
public interface BeeLineSignalHandler {
public void setStatement(Statement stmt);
void setStatement(Statement stmt);
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
class BooleanCompleter extends StringsCompleter {

public BooleanCompleter() {
super(new String[] {"true", "false"});
super("true", "false");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package org.apache.hive.beeline;

import java.sql.SQLException;
import org.apache.hive.jdbc.Utils;
import org.apache.kyuubi.jdbc.hive.Utils;

/** We need to update some client side information after executing some Hive Commands */
public class ClientCommandHookFactory {
Expand All @@ -30,7 +30,7 @@ public static ClientCommandHookFactory get() {
return instance;
}

public class SetCommandHook extends ClientHook {
public static class SetCommandHook extends ClientHook {

public SetCommandHook(String sql) {
super(sql);
Expand All @@ -44,7 +44,7 @@ public void postHook(BeeLine beeLine) {
}
}

public class UseCommandHook extends ClientHook {
public static class UseCommandHook extends ClientHook {

public UseCommandHook(String sql) {
super(sql);
Expand All @@ -66,7 +66,7 @@ public void postHook(BeeLine beeLine) {
}
}

public class ConnectCommandHook extends ClientHook {
public static class ConnectCommandHook extends ClientHook {

public ConnectCommandHook(String sql) {
super(sql);
Expand All @@ -93,7 +93,7 @@ public void postHook(BeeLine beeLine) {
}
}

public class GoCommandHook extends ClientHook {
public static class GoCommandHook extends ClientHook {

public GoCommandHook(String sql) {
super(sql);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,36 +31,36 @@
*/
interface CommandHandler {
/** @return the name of the command */
public String getName();
String getName();

/** @return all the possible names of this command. */
public String[] getNames();
String[] getNames();

/** @return the short help description for this command. */
public String getHelpText();
String getHelpText();

/**
* Check to see if the specified string can be dispatched to this command.
*
* @param line the command line to check.
* @return the command string that matches, or null if it no match
*/
public String matches(String line);
String matches(String line);

/**
* Execute the specified command.
*
* @param line the full command line to execute.
*/
public boolean execute(String line);
boolean execute(String line);

/** Returns the completors that can handle parameters. */
public Completer[] getParameterCompleters();
Completer[] getParameterCompleters();

/**
* Returns exception thrown for last command
*
* @return
*/
public Throwable getLastException();
Throwable getLastException();
}
Loading

0 comments on commit 898a24e

Please sign in to comment.