Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 38 additions & 27 deletions beeline/src/java/org/apache/hive/beeline/BeeLine.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@

import com.google.common.annotations.VisibleForTesting;

import org.jline.builtins.Completers.FileNameCompleter;
import org.jline.reader.Completer;
import org.jline.reader.EndOfFileException;
import org.jline.reader.History;
Expand All @@ -121,25 +122,6 @@
import org.jline.terminal.Terminal;
import org.jline.terminal.TerminalBuilder;

import static org.jline.builtins.Completers.FileNameCompleter;


/**
* A console SQL shell with command completion.
* <p>
* TODO:
* <ul>
* <li>User-friendly connection prompts</li>
* <li>Page results</li>
* <li>Handle binary data (blob fields)</li>
* <li>Implement command aliases</li>
* <li>Stored procedure execution</li>
* <li>Binding parameters to prepared statements</li>
* <li>Scripting language</li>
* <li>XA transactions</li>
* </ul>
*
*/
@SuppressWarnings("static-access")
public class BeeLine implements Closeable {
private static final ResourceBundle resourceBundle =
Expand Down Expand Up @@ -468,21 +450,50 @@ String getManifestAttribute(String name) {
}
}


String getApplicationBanner() {
Package pack = BeeLine.class.getPackage();
String version =
pack.getImplementationVersion() == null ? "" : pack.getImplementationVersion();
String sep = System.lineSeparator();
boolean color = bannerColorEnabled();
String yellow = color ? "\u001b[1;33m" : "";
String reset = color ? "\u001b[0m" : "";
return new StringBuilder(512)
.append(yellow)
.append(" _ _ _____ _______").append(sep)
.append(" | | | |_ _\\ \\ / / ____|").append(sep)
.append(" | |_| || | \\ \\ / /| _|").append(sep)
.append(" | _ || | \\ V / | |___").append(sep)
.append(" |_| |_|___| \\_/ |_____|").append(reset).append(sep)
.append(sep)
.append("Apache Hive " + version + " - Beeline").append(sep)
.append("The Open Data Warehouse for Modern Analytics").append(sep)
.toString();
}


String getApplicationTitle() {
Package pack = BeeLine.class.getPackage();

return loc("app-introduction", new Object[] { "Beeline",
pack.getImplementationVersion() == null ? "???" : pack.getImplementationVersion(),
"Apache Hive",
// getManifestAttribute ("Specification-Title"),
// getManifestAttribute ("Implementation-Version"),
// getManifestAttribute ("Implementation-ReleaseDate"),
// getManifestAttribute ("Implementation-Vendor"),
// getManifestAttribute ("Implementation-License"),
});
}

/** True when the active terminal can display ANSI colors (not dumb/redirected). */
private boolean bannerColorEnabled() {
try {
LineReader lr = getLineReader();
if (lr != null && lr.getTerminal() != null) {
String type = lr.getTerminal().getType();
return type != null && !Terminal.TYPE_DUMB.equals(type);
}
} catch (Exception e) {
// no usable terminal -> stay monochrome
}
return false;
}

String getApplicationContactInformation() {
return getManifestAttribute("Implementation-Vendor");
}
Expand Down Expand Up @@ -1139,7 +1150,7 @@ public int begin(String[] args, InputStream inputStream, boolean keepHistory) th
return executeFile(getOpts().getScriptFile());
}
try {
info(getApplicationTitle());
info(getApplicationBanner());
} catch (Exception e) {
// ignore
}
Expand Down
2 changes: 1 addition & 1 deletion beeline/src/java/org/apache/hive/beeline/BeeLineOpts.java
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ public void save() throws IOException {
}
}

public void save(OutputStream out) throws IOException {
public void save(OutputStream out) {
try {
Properties props = toProperties();
// don't save maxwidth: it is automatically set based on
Expand Down