From ef45343939b6c74fb9543c5eabd4001e4d431857 Mon Sep 17 00:00:00 2001 From: Rusty Phillips Date: Wed, 28 Oct 2015 17:29:49 -0400 Subject: [PATCH 1/3] Added new interpreter result code. --- .../zeppelin/hive/ForgivingHiveResultSet.java | 828 ++++++++++++++++++ .../hive/ForgivingHiveResultSetMetadata.java | 111 +++ .../apache/zeppelin/hive/HiveInterpreter.java | 27 +- zeppelin-interpreter/pom.xml | 7 + .../interpreter/JdbcInterpreterResult.java | 140 +++ .../apache/zeppelin/server/JsonResponse.java | 1 + .../zeppelin/server/ZeppelinServer.java | 7 +- .../interpreter/FilesystemResultRepo.java | 164 ++++ .../interpreter/InterpreterFactory.java | 27 +- .../InterpreterResultSerializer.java | 82 ++ .../interpreter/RemoteResultRepo.java | 68 ++ .../interpreter/ResultRepoFactory.java | 62 ++ .../notebook/NoteInterpreterLoader.java | 8 + .../apache/zeppelin/notebook/Notebook.java | 9 +- .../apache/zeppelin/notebook/Paragraph.java | 40 +- .../notebook/ParagraphSerializer.java | 117 +++ .../notebook/repo/S3NotebookRepo.java | 13 +- .../notebook/repo/VFSNotebookRepo.java | 15 +- 18 files changed, 1678 insertions(+), 48 deletions(-) create mode 100644 hive/src/main/java/org/apache/zeppelin/hive/ForgivingHiveResultSet.java create mode 100644 hive/src/main/java/org/apache/zeppelin/hive/ForgivingHiveResultSetMetadata.java create mode 100644 zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/JdbcInterpreterResult.java create mode 100644 zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/FilesystemResultRepo.java create mode 100644 zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterResultSerializer.java create mode 100644 zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/RemoteResultRepo.java create mode 100644 zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/ResultRepoFactory.java create mode 100644 zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/ParagraphSerializer.java diff --git a/hive/src/main/java/org/apache/zeppelin/hive/ForgivingHiveResultSet.java b/hive/src/main/java/org/apache/zeppelin/hive/ForgivingHiveResultSet.java new file mode 100644 index 00000000000..30633d26c49 --- /dev/null +++ b/hive/src/main/java/org/apache/zeppelin/hive/ForgivingHiveResultSet.java @@ -0,0 +1,828 @@ +package org.apache.zeppelin.hive; + +import org.apache.hive.jdbc.HiveQueryResultSet; + +import java.io.InputStream; +import java.io.Reader; +import java.math.BigDecimal; +import java.net.URL; +import java.sql.Array; +import java.sql.Blob; +import java.sql.Clob; +import java.sql.Date; +import java.sql.NClob; +import java.sql.Ref; +import java.sql.ResultSet; +import java.sql.ResultSetMetaData; +import java.sql.RowId; +import java.sql.SQLException; +import java.sql.SQLType; +import java.sql.SQLWarning; +import java.sql.SQLXML; +import java.sql.Statement; +import java.sql.Time; +import java.sql.Timestamp; +import java.util.Calendar; +import java.util.Map; +/** + * Overwrites the not supported Hive methods with ones that say + * that a column doesn't have a given feature. + * This allows hive to work properly with cached result sets. + * + * @author Rusty Phillips {@literal: } + * + */ +public class ForgivingHiveResultSet implements ResultSet { + ResultSet inner_results; + + public int hashCode() { + return inner_results.hashCode(); + } + + public boolean absolute(int row) throws SQLException { + return inner_results.absolute(row); + } + + public void afterLast() throws SQLException { + inner_results.afterLast(); + } + + public void cancelRowUpdates() throws SQLException { + inner_results.cancelRowUpdates(); + } + + public void deleteRow() throws SQLException { + inner_results.deleteRow(); + } + + public int findColumn(String columnName) throws SQLException { + return inner_results.findColumn(columnName); + } + + public boolean first() throws SQLException { + return inner_results.first(); + } + + public Array getArray(int i) throws SQLException { + return inner_results.getArray(i); + } + + public Array getArray(String colName) throws SQLException { + return inner_results.getArray(colName); + } + + public InputStream getAsciiStream(int columnIndex) throws SQLException { + return inner_results.getAsciiStream(columnIndex); + } + + public InputStream getAsciiStream(String columnName) throws SQLException { + return inner_results.getAsciiStream(columnName); + } + + public boolean equals(Object obj) { + return inner_results.equals(obj); + } + + public BigDecimal getBigDecimal(int columnIndex) throws SQLException { + return inner_results.getBigDecimal(columnIndex); + } + + public BigDecimal getBigDecimal(String columnName) throws SQLException { + return inner_results.getBigDecimal(columnName); + } + + public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException { + return inner_results.getBigDecimal(columnIndex, scale); + } + + public BigDecimal getBigDecimal(String columnName, int scale) throws SQLException { + return inner_results.getBigDecimal(columnName, scale); + } + + public InputStream getBinaryStream(int columnIndex) throws SQLException { + return inner_results.getBinaryStream(columnIndex); + } + + public InputStream getBinaryStream(String columnName) throws SQLException { + return inner_results.getBinaryStream(columnName); + } + + public Blob getBlob(int i) throws SQLException { + return inner_results.getBlob(i); + } + + public Blob getBlob(String colName) throws SQLException { + return inner_results.getBlob(colName); + } + + public boolean getBoolean(int columnIndex) throws SQLException { + return inner_results.getBoolean(columnIndex); + } + + public boolean getBoolean(String columnName) throws SQLException { + return inner_results.getBoolean(columnName); + } + + public byte getByte(int columnIndex) throws SQLException { + return inner_results.getByte(columnIndex); + } + + public byte getByte(String columnName) throws SQLException { + return inner_results.getByte(columnName); + } + + public byte[] getBytes(int columnIndex) throws SQLException { + return inner_results.getBytes(columnIndex); + } + + public byte[] getBytes(String columnName) throws SQLException { + return inner_results.getBytes(columnName); + } + + public Reader getCharacterStream(int columnIndex) throws SQLException { + return inner_results.getCharacterStream(columnIndex); + } + + public Reader getCharacterStream(String columnName) throws SQLException { + return inner_results.getCharacterStream(columnName); + } + + public Clob getClob(int i) throws SQLException { + return inner_results.getClob(i); + } + + public Clob getClob(String colName) throws SQLException { + return inner_results.getClob(colName); + } + + public int getConcurrency() throws SQLException { + return inner_results.getConcurrency(); + } + + public String getCursorName() throws SQLException { + return inner_results.getCursorName(); + } + + public Date getDate(int columnIndex) throws SQLException { + return inner_results.getDate(columnIndex); + } + + public Date getDate(String columnName) throws SQLException { + return inner_results.getDate(columnName); + } + + public Date getDate(int columnIndex, Calendar cal) throws SQLException { + return inner_results.getDate(columnIndex, cal); + } + + public Date getDate(String columnName, Calendar cal) throws SQLException { + return inner_results.getDate(columnName, cal); + } + + public double getDouble(int columnIndex) throws SQLException { + return inner_results.getDouble(columnIndex); + } + + public double getDouble(String columnName) throws SQLException { + return inner_results.getDouble(columnName); + } + + public int getFetchDirection() throws SQLException { + return inner_results.getFetchDirection(); + } + + public String toString() { + return inner_results.toString(); + } + + public float getFloat(int columnIndex) throws SQLException { + return inner_results.getFloat(columnIndex); + } + + public float getFloat(String columnName) throws SQLException { + return inner_results.getFloat(columnName); + } + + public int getHoldability() throws SQLException { + return inner_results.getHoldability(); + } + + public int getInt(int columnIndex) throws SQLException { + return inner_results.getInt(columnIndex); + } + + public int getInt(String columnName) throws SQLException { + return inner_results.getInt(columnName); + } + + public long getLong(int columnIndex) throws SQLException { + return inner_results.getLong(columnIndex); + } + + public void close() throws SQLException { + inner_results.close(); + } + + public boolean next() throws SQLException { + return inner_results.next(); + } + + public long getLong(String columnName) throws SQLException { + return inner_results.getLong(columnName); + } + + public Reader getNCharacterStream(int arg0) throws SQLException { + return inner_results.getNCharacterStream(arg0); + } + + public Reader getNCharacterStream(String arg0) throws SQLException { + return inner_results.getNCharacterStream(arg0); + } + + public NClob getNClob(int arg0) throws SQLException { + return inner_results.getNClob(arg0); + } + + public NClob getNClob(String columnLabel) throws SQLException { + return inner_results.getNClob(columnLabel); + } + + public String getNString(int columnIndex) throws SQLException { + return inner_results.getNString(columnIndex); + } + + public String getNString(String columnLabel) throws SQLException { + return inner_results.getNString(columnLabel); + } + + public ResultSetMetaData getMetaData() throws SQLException { + return new ForgivingHiveResultSetMetadata(inner_results.getMetaData()); + } + + public void setFetchSize(int rows) throws SQLException { + inner_results.setFetchSize(rows); + } + + public int getType() throws SQLException { + return inner_results.getType(); + } + + public Object getObject(int columnIndex) throws SQLException { + return inner_results.getObject(columnIndex); + } + + public int getFetchSize() throws SQLException { + return inner_results.getFetchSize(); + } + + public Object getObject(String columnName) throws SQLException { + return inner_results.getObject(columnName); + } + + public Object getObject(int i, Map> map) throws SQLException { + return inner_results.getObject(i, map); + } + + public T getObject(String columnLabel, Class type) throws SQLException { + return inner_results.getObject(columnLabel, type); + } + + public Object getObject(String colName, Map> map) throws SQLException { + return inner_results.getObject(colName, map); + } + + public T getObject(int columnIndex, Class type) throws SQLException { + return inner_results.getObject(columnIndex, type); + } + + public Ref getRef(int i) throws SQLException { + return inner_results.getRef(i); + } + + public void beforeFirst() throws SQLException { + inner_results.beforeFirst(); + } + + public Ref getRef(String colName) throws SQLException { + return inner_results.getRef(colName); + } + + public RowId getRowId(int columnIndex) throws SQLException { + return inner_results.getRowId(columnIndex); + } + + public RowId getRowId(String columnLabel) throws SQLException { + return inner_results.getRowId(columnLabel); + } + + public boolean isBeforeFirst() throws SQLException { + return inner_results.isBeforeFirst(); + } + + public SQLXML getSQLXML(int columnIndex) throws SQLException { + return inner_results.getSQLXML(columnIndex); + } + + public SQLXML getSQLXML(String columnLabel) throws SQLException { + return inner_results.getSQLXML(columnLabel); + } + + public int getRow() throws SQLException { + return inner_results.getRow(); + } + + public short getShort(int columnIndex) throws SQLException { + return inner_results.getShort(columnIndex); + } + + public short getShort(String columnName) throws SQLException { + return inner_results.getShort(columnName); + } + + public Statement getStatement() throws SQLException { + return inner_results.getStatement(); + } + + public String getString(int columnIndex) throws SQLException { + return inner_results.getString(columnIndex); + } + + public String getString(String columnName) throws SQLException { + return inner_results.getString(columnName); + } + + public Time getTime(int columnIndex) throws SQLException { + return inner_results.getTime(columnIndex); + } + + public Time getTime(String columnName) throws SQLException { + return inner_results.getTime(columnName); + } + + public Time getTime(int columnIndex, Calendar cal) throws SQLException { + return inner_results.getTime(columnIndex, cal); + } + + public Time getTime(String columnName, Calendar cal) throws SQLException { + return inner_results.getTime(columnName, cal); + } + + public Timestamp getTimestamp(int columnIndex) throws SQLException { + return inner_results.getTimestamp(columnIndex); + } + + public Timestamp getTimestamp(String columnName) throws SQLException { + return inner_results.getTimestamp(columnName); + } + + public Timestamp getTimestamp(int columnIndex, Calendar cal) throws SQLException { + return inner_results.getTimestamp(columnIndex, cal); + } + + public Timestamp getTimestamp(String columnName, Calendar cal) throws SQLException { + return inner_results.getTimestamp(columnName, cal); + } + + public URL getURL(int columnIndex) throws SQLException { + return inner_results.getURL(columnIndex); + } + + public URL getURL(String columnName) throws SQLException { + return inner_results.getURL(columnName); + } + + public InputStream getUnicodeStream(int columnIndex) throws SQLException { + return inner_results.getUnicodeStream(columnIndex); + } + + public InputStream getUnicodeStream(String columnName) throws SQLException { + return inner_results.getUnicodeStream(columnName); + } + + public void insertRow() throws SQLException { + inner_results.insertRow(); + } + + public boolean isAfterLast() throws SQLException { + return inner_results.isAfterLast(); + } + + public boolean isClosed() throws SQLException { + return inner_results.isClosed(); + } + + public boolean isFirst() throws SQLException { + return inner_results.isFirst(); + } + + public boolean isLast() throws SQLException { + return inner_results.isLast(); + } + + public boolean last() throws SQLException { + return inner_results.last(); + } + + public void moveToCurrentRow() throws SQLException { + inner_results.moveToCurrentRow(); + } + + public void moveToInsertRow() throws SQLException { + inner_results.moveToInsertRow(); + } + + public boolean previous() throws SQLException { + return inner_results.previous(); + } + + public void refreshRow() throws SQLException { + inner_results.refreshRow(); + } + + public boolean relative(int rows) throws SQLException { + return inner_results.relative(rows); + } + + public boolean rowDeleted() throws SQLException { + return inner_results.rowDeleted(); + } + + public boolean rowInserted() throws SQLException { + return inner_results.rowInserted(); + } + + public boolean rowUpdated() throws SQLException { + return inner_results.rowUpdated(); + } + + public void setFetchDirection(int direction) throws SQLException { + inner_results.setFetchDirection(direction); + } + + public void updateArray(int columnIndex, Array x) throws SQLException { + inner_results.updateArray(columnIndex, x); + } + + public void updateArray(String columnName, Array x) throws SQLException { + inner_results.updateArray(columnName, x); + } + + public void updateAsciiStream(int columnIndex, InputStream x) throws SQLException { + inner_results.updateAsciiStream(columnIndex, x); + } + + public void updateAsciiStream(String columnLabel, InputStream x) throws SQLException { + inner_results.updateAsciiStream(columnLabel, x); + } + + public void updateAsciiStream(int columnIndex, InputStream x, int length) throws SQLException { + inner_results.updateAsciiStream(columnIndex, x, length); + } + + public void updateAsciiStream(String columnName, InputStream x, int length) throws SQLException { + inner_results.updateAsciiStream(columnName, x, length); + } + + public void updateAsciiStream(int columnIndex, InputStream x, long length) throws SQLException { + inner_results.updateAsciiStream(columnIndex, x, length); + } + + public void updateAsciiStream(String columnLabel, + InputStream x, + long length) throws SQLException { + inner_results.updateAsciiStream(columnLabel, x, length); + } + + public void updateBigDecimal(int columnIndex, BigDecimal x) throws SQLException { + inner_results.updateBigDecimal(columnIndex, x); + } + + public void updateBigDecimal(String columnName, BigDecimal x) throws SQLException { + inner_results.updateBigDecimal(columnName, x); + } + + public void updateBinaryStream(int columnIndex, InputStream x) throws SQLException { + inner_results.updateBinaryStream(columnIndex, x); + } + + public void updateBinaryStream(String columnLabel, InputStream x) throws SQLException { + inner_results.updateBinaryStream(columnLabel, x); + } + + public void updateBinaryStream(int columnIndex, InputStream x, int length) throws SQLException { + inner_results.updateBinaryStream(columnIndex, x, length); + } + + public void updateBinaryStream(String columnName, InputStream x, int length) throws SQLException { + inner_results.updateBinaryStream(columnName, x, length); + } + + public void updateBinaryStream(int columnIndex, InputStream x, long length) throws SQLException { + inner_results.updateBinaryStream(columnIndex, x, length); + } + + public void updateBinaryStream(String columnLabel, + InputStream x, long length) throws SQLException { + inner_results.updateBinaryStream(columnLabel, x, length); + } + + public void updateBlob(int columnIndex, Blob x) throws SQLException { + inner_results.updateBlob(columnIndex, x); + } + + public void updateBlob(String columnName, Blob x) throws SQLException { + inner_results.updateBlob(columnName, x); + } + + public void updateBlob(int columnIndex, InputStream inputStream) throws SQLException { + inner_results.updateBlob(columnIndex, inputStream); + } + + public void updateBlob(String columnLabel, InputStream inputStream) throws SQLException { + inner_results.updateBlob(columnLabel, inputStream); + } + + public void updateBlob(int columnIndex, InputStream inputStream, long length) + throws SQLException { + inner_results.updateBlob(columnIndex, inputStream, length); + } + + public void updateBlob(String columnLabel, InputStream inputStream, long length) + throws SQLException { + inner_results.updateBlob(columnLabel, inputStream, length); + } + + public void updateBoolean(int columnIndex, boolean x) throws SQLException { + inner_results.updateBoolean(columnIndex, x); + } + + public void updateBoolean(String columnName, boolean x) throws SQLException { + inner_results.updateBoolean(columnName, x); + } + + public void updateByte(int columnIndex, byte x) throws SQLException { + inner_results.updateByte(columnIndex, x); + } + + public void updateByte(String columnName, byte x) throws SQLException { + inner_results.updateByte(columnName, x); + } + + public void updateBytes(int columnIndex, byte[] x) throws SQLException { + inner_results.updateBytes(columnIndex, x); + } + + public void updateBytes(String columnName, byte[] x) throws SQLException { + inner_results.updateBytes(columnName, x); + } + + public void updateCharacterStream(int columnIndex, Reader x) throws SQLException { + inner_results.updateCharacterStream(columnIndex, x); + } + + public void updateCharacterStream(String columnLabel, Reader reader) throws SQLException { + inner_results.updateCharacterStream(columnLabel, reader); + } + + public void updateCharacterStream(int columnIndex, Reader x, int length) throws SQLException { + inner_results.updateCharacterStream(columnIndex, x, length); + } + + public void updateCharacterStream(String columnName, Reader reader, int length) + throws SQLException { + inner_results.updateCharacterStream(columnName, reader, length); + } + + public void updateCharacterStream(int columnIndex, Reader x, long length) throws SQLException { + inner_results.updateCharacterStream(columnIndex, x, length); + } + + public void updateCharacterStream(String columnLabel, Reader reader, long length) + throws SQLException { + inner_results.updateCharacterStream(columnLabel, reader, length); + } + + public void updateClob(int columnIndex, Clob x) throws SQLException { + inner_results.updateClob(columnIndex, x); + } + + public void updateClob(String columnName, Clob x) throws SQLException { + inner_results.updateClob(columnName, x); + } + + public void updateClob(int columnIndex, Reader reader) throws SQLException { + inner_results.updateClob(columnIndex, reader); + } + + public void updateClob(String columnLabel, Reader reader) throws SQLException { + inner_results.updateClob(columnLabel, reader); + } + + public void updateClob(int columnIndex, Reader reader, long length) throws SQLException { + inner_results.updateClob(columnIndex, reader, length); + } + + public void updateClob(String columnLabel, Reader reader, long length) throws SQLException { + inner_results.updateClob(columnLabel, reader, length); + } + + public void updateDate(int columnIndex, Date x) throws SQLException { + inner_results.updateDate(columnIndex, x); + } + + public void updateDate(String columnName, Date x) throws SQLException { + inner_results.updateDate(columnName, x); + } + + public void updateDouble(int columnIndex, double x) throws SQLException { + inner_results.updateDouble(columnIndex, x); + } + + public void updateDouble(String columnName, double x) throws SQLException { + inner_results.updateDouble(columnName, x); + } + + public void updateFloat(int columnIndex, float x) throws SQLException { + inner_results.updateFloat(columnIndex, x); + } + + public void updateFloat(String columnName, float x) throws SQLException { + inner_results.updateFloat(columnName, x); + } + + public void updateInt(int columnIndex, int x) throws SQLException { + inner_results.updateInt(columnIndex, x); + } + + public void updateInt(String columnName, int x) throws SQLException { + inner_results.updateInt(columnName, x); + } + + public void updateLong(int columnIndex, long x) throws SQLException { + inner_results.updateLong(columnIndex, x); + } + + public void updateLong(String columnName, long x) throws SQLException { + inner_results.updateLong(columnName, x); + } + + public void updateNCharacterStream(int columnIndex, Reader x) throws SQLException { + inner_results.updateNCharacterStream(columnIndex, x); + } + + public void updateNCharacterStream(String columnLabel, Reader reader) throws SQLException { + inner_results.updateNCharacterStream(columnLabel, reader); + } + + public void updateNCharacterStream(int columnIndex, Reader x, long length) throws SQLException { + inner_results.updateNCharacterStream(columnIndex, x, length); + } + + public void updateNCharacterStream(String columnLabel, Reader reader, long length) + throws SQLException { + inner_results.updateNCharacterStream(columnLabel, reader, length); + } + + public void updateNClob(int columnIndex, NClob clob) throws SQLException { + inner_results.updateNClob(columnIndex, clob); + } + + public void updateNClob(String columnLabel, NClob clob) throws SQLException { + inner_results.updateNClob(columnLabel, clob); + } + + public void updateNClob(int columnIndex, Reader reader) throws SQLException { + inner_results.updateNClob(columnIndex, reader); + } + + public void updateNClob(String columnLabel, Reader reader) throws SQLException { + inner_results.updateNClob(columnLabel, reader); + } + + public void updateNClob(int columnIndex, Reader reader, long length) throws SQLException { + inner_results.updateNClob(columnIndex, reader, length); + } + + public void updateNClob(String columnLabel, Reader reader, long length) throws SQLException { + inner_results.updateNClob(columnLabel, reader, length); + } + + public void updateNString(int columnIndex, String string) throws SQLException { + inner_results.updateNString(columnIndex, string); + } + + public void updateNString(String columnLabel, String string) throws SQLException { + inner_results.updateNString(columnLabel, string); + } + + public void updateNull(int columnIndex) throws SQLException { + inner_results.updateNull(columnIndex); + } + + public void updateNull(String columnName) throws SQLException { + inner_results.updateNull(columnName); + } + + public void updateObject(int columnIndex, Object x) throws SQLException { + inner_results.updateObject(columnIndex, x); + } + + public void updateObject(String columnName, Object x) throws SQLException { + inner_results.updateObject(columnName, x); + } + + public void updateObject(int columnIndex, Object x, int scale) throws SQLException { + inner_results.updateObject(columnIndex, x, scale); + } + + public void updateObject(String columnName, Object x, int scale) throws SQLException { + inner_results.updateObject(columnName, x, scale); + } + + public void updateRef(int columnIndex, Ref x) throws SQLException { + inner_results.updateRef(columnIndex, x); + } + + public void updateRef(String columnName, Ref x) throws SQLException { + inner_results.updateRef(columnName, x); + } + + public void updateRow() throws SQLException { + inner_results.updateRow(); + } + + public void updateRowId(int columnIndex, RowId x) throws SQLException { + inner_results.updateRowId(columnIndex, x); + } + + public void updateRowId(String columnLabel, RowId x) throws SQLException { + inner_results.updateRowId(columnLabel, x); + } + + public void updateSQLXML(int columnIndex, SQLXML xmlObject) throws SQLException { + inner_results.updateSQLXML(columnIndex, xmlObject); + } + + public void updateSQLXML(String columnLabel, SQLXML xmlObject) throws SQLException { + inner_results.updateSQLXML(columnLabel, xmlObject); + } + + public void updateShort(int columnIndex, short x) throws SQLException { + inner_results.updateShort(columnIndex, x); + } + + public void updateShort(String columnName, short x) throws SQLException { + inner_results.updateShort(columnName, x); + } + + public void updateString(int columnIndex, String x) throws SQLException { + inner_results.updateString(columnIndex, x); + } + + public void updateString(String columnName, String x) throws SQLException { + inner_results.updateString(columnName, x); + } + + public void updateTime(int columnIndex, Time x) throws SQLException { + inner_results.updateTime(columnIndex, x); + } + + public void updateTime(String columnName, Time x) throws SQLException { + inner_results.updateTime(columnName, x); + } + + public void updateTimestamp(int columnIndex, Timestamp x) throws SQLException { + inner_results.updateTimestamp(columnIndex, x); + } + + public void updateTimestamp(String columnName, Timestamp x) throws SQLException { + inner_results.updateTimestamp(columnName, x); + } + + public SQLWarning getWarnings() throws SQLException { + return inner_results.getWarnings(); + } + + public void clearWarnings() throws SQLException { + inner_results.clearWarnings(); + } + + public boolean wasNull() throws SQLException { + return inner_results.wasNull(); + } + + public boolean isWrapperFor(Class iface) throws SQLException { + return inner_results.isWrapperFor(iface); + } + + public T unwrap(Class iface) throws SQLException { + return inner_results.unwrap(iface); + } + + public ForgivingHiveResultSet(ResultSet source) + { + this.inner_results = source; + } + + +} diff --git a/hive/src/main/java/org/apache/zeppelin/hive/ForgivingHiveResultSetMetadata.java b/hive/src/main/java/org/apache/zeppelin/hive/ForgivingHiveResultSetMetadata.java new file mode 100644 index 00000000000..85e0067b0b0 --- /dev/null +++ b/hive/src/main/java/org/apache/zeppelin/hive/ForgivingHiveResultSetMetadata.java @@ -0,0 +1,111 @@ +package org.apache.zeppelin.hive; + +import java.sql.ResultSetMetaData; +import java.sql.SQLException; +/** + * Hive does not implement all of the methods needed by CachedResultSet, + * but it could have a sensible default implementation that will work. + * @author Rusty Phillips {@literal: } + * + */ +public class ForgivingHiveResultSetMetadata implements ResultSetMetaData { + + ResultSetMetaData innerMetaData; + + public ForgivingHiveResultSetMetadata(ResultSetMetaData metaData) { + this.innerMetaData = metaData; + } + + public T unwrap(Class iface) throws SQLException { + return innerMetaData.unwrap(iface); + } + + public int getColumnCount() throws SQLException { + return innerMetaData.getColumnCount(); + } + + public boolean isAutoIncrement(int column) throws SQLException { + return innerMetaData.isAutoIncrement(column); + } + + public boolean isCaseSensitive(int column) throws SQLException { + return innerMetaData.isCaseSensitive(column); + } + + public boolean isSearchable(int column) throws SQLException { + return false; + } + + public boolean isWrapperFor(Class iface) throws SQLException { + return innerMetaData.isWrapperFor(iface); + } + + public boolean isCurrency(int column) throws SQLException { + return false; + } + + public int isNullable(int column) throws SQLException { + return innerMetaData.isNullable(column); + } + + public boolean isSigned(int column) throws SQLException { + return false; + } + + public int getColumnDisplaySize(int column) throws SQLException { + return innerMetaData.getColumnDisplaySize(column); + } + + public String getColumnLabel(int column) throws SQLException { + return innerMetaData.getColumnLabel(column); + } + + public String getColumnName(int column) throws SQLException { + return innerMetaData.getColumnName(column); + } + + public String getSchemaName(int column) throws SQLException { + return ""; + } + + public int getPrecision(int column) throws SQLException { + return innerMetaData.getPrecision(column); + } + + public int getScale(int column) throws SQLException { + return innerMetaData.getScale(column); + } + + public String getTableName(int column) throws SQLException { + return ""; + } + + public String getCatalogName(int column) throws SQLException { + return ""; + } + + public int getColumnType(int column) throws SQLException { + return innerMetaData.getColumnType(column); + } + + public String getColumnTypeName(int column) throws SQLException { + return innerMetaData.getColumnTypeName(column); + } + + public boolean isReadOnly(int column) throws SQLException { + return innerMetaData.isReadOnly(column); + } + + public boolean isWritable(int column) throws SQLException { + return innerMetaData.isWritable(column); + } + + public boolean isDefinitelyWritable(int column) throws SQLException { + return innerMetaData.isDefinitelyWritable(column); + } + + public String getColumnClassName(int column) throws SQLException { + return innerMetaData.getColumnClassName(column); + } + +} diff --git a/hive/src/main/java/org/apache/zeppelin/hive/HiveInterpreter.java b/hive/src/main/java/org/apache/zeppelin/hive/HiveInterpreter.java index 5c3dee37387..f44393d29ef 100644 --- a/hive/src/main/java/org/apache/zeppelin/hive/HiveInterpreter.java +++ b/hive/src/main/java/org/apache/zeppelin/hive/HiveInterpreter.java @@ -32,11 +32,15 @@ import org.apache.zeppelin.interpreter.InterpreterPropertyBuilder; import org.apache.zeppelin.interpreter.InterpreterResult; import org.apache.zeppelin.interpreter.InterpreterResult.Code; +import org.apache.zeppelin.interpreter.JdbcInterpreterResult; import org.apache.zeppelin.scheduler.Scheduler; import org.apache.zeppelin.scheduler.SchedulerFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; + /** * Hive interpreter for Zeppelin. */ @@ -117,10 +121,12 @@ public void close() { Statement currentStatement; private InterpreterResult executeSql(String sql) { try { + logger.debug("Running execute."); if (exceptionOnConnect != null) { return new InterpreterResult(Code.ERROR, exceptionOnConnect.getMessage()); } currentStatement = jdbcConnection.createStatement(); + logger.debug("Created statement."); StringBuilder msg = null; if (StringUtils.containsIgnoreCase(sql, "EXPLAIN ")) { //return the explain as text, make this visual explain later @@ -129,23 +135,12 @@ private InterpreterResult executeSql(String sql) { else { msg = new StringBuilder("%table "); } + logger.debug("Building JDBC result"); + ResultSet res = currentStatement.executeQuery(sql); + try { - ResultSetMetaData md = res.getMetaData(); - for (int i = 1; i < md.getColumnCount() + 1; i++) { - if (i == 1) { - msg.append(md.getColumnName(i)); - } else { - msg.append("\t" + md.getColumnName(i)); - } - } - msg.append("\n"); - while (res.next()) { - for (int i = 1; i < md.getColumnCount() + 1; i++) { - msg.append(res.getString(i) + "\t"); - } - msg.append("\n"); - } + return new JdbcInterpreterResult(Code.SUCCESS, res); } finally { try { @@ -157,8 +152,6 @@ private InterpreterResult executeSql(String sql) { } } - InterpreterResult rett = new InterpreterResult(Code.SUCCESS, msg.toString()); - return rett; } catch (SQLException ex) { logger.error("Can not run " + sql, ex); diff --git a/zeppelin-interpreter/pom.xml b/zeppelin-interpreter/pom.xml index edfa5e3d31c..8bc15b48685 100644 --- a/zeppelin-interpreter/pom.xml +++ b/zeppelin-interpreter/pom.xml @@ -92,5 +92,12 @@ commons-lang3 3.3.2 + + + org.apache.commons + commons-vfs2 + 2.0 + + diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/JdbcInterpreterResult.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/JdbcInterpreterResult.java new file mode 100644 index 00000000000..1931904b5b2 --- /dev/null +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/JdbcInterpreterResult.java @@ -0,0 +1,140 @@ +package org.apache.zeppelin.interpreter; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.sql.ResultSet; +import java.sql.ResultSetMetaData; + +import javax.sql.rowset.RowSetProvider; +import javax.sql.rowset.CachedRowSet; +import java.sql.SQLException; + + +import org.apache.commons.codec.binary.StringUtils; +import java.util.UUID; +import com.google.gson.GsonBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Unlike a regular interpreter result, a JdbcInterpreter Result caches its + * output so that it can be used later and persisted independently of the regular result. + * It also has a standard return for all tabular SQL data. + * @author Rusty Phillips {@literal: } + * + */ +public class JdbcInterpreterResult extends InterpreterResult { + + private ResultSet results; + private String id; + private String repoName; + + private InterpreterResult innerResult; + + private Logger logger() { + + Logger logger = LoggerFactory.getLogger(JdbcInterpreterResult.class); + return logger; + } + + + public String getRepoName() { + return repoName; + } + + public void setRepoName(String repoName) { + this.repoName = repoName; + } + + public ResultSet getResults() { + return results; + } + + + public JdbcInterpreterResult(Code code, String Id) + { + super(code); + this.type = Type.TABLE; + this.setId(Id); + } + + public JdbcInterpreterResult(Code code, ResultSet resultSet) { + this(code, resultSet, + UUID.randomUUID().toString()); + } + + public JdbcInterpreterResult(Code code, ResultSet resultSet, String Id) { + super(code); + try { + + this.type = Type.TABLE; + // Not necessary at this time, but may be something to consider in the future. + // the results in memory, it is not necessarily a better option than the previous one. + /* + CachedRowSet impl = RowSetProvider.newFactory().createCachedRowSet(); + logger().debug("Populating result set"); + impl.populate(resultSet); + */ + logger().debug("Finished populating result set."); + this.results = resultSet; + this.id = Id; + message(); + } catch (Exception ex) { + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + this.code = code.ERROR; + ex.printStackTrace(pw); + logger().debug("Failed to populate result set.\n{}\n{}", + ex.getMessage(), sw.toString()); + this.msg = ex.getMessage(); + } + } + + + @Override + public String message() { + if (this.msg != null) + { + return this.msg; + } + + StringBuilder msg = new StringBuilder(); + if (code == code.ERROR) { return this.msg; } + try { + if (this.results == null) + { + this.code = code.ERROR; + this.msg = "Unable to find any results table"; + return this.msg; + } + ResultSetMetaData md = this.results.getMetaData(); + for (int i = 1; i < md.getColumnCount() + 1; i++) { + if (i == 1) { + msg.append(md.getColumnName(i)); + } else { + msg.append("\t" + md.getColumnName(i)); + } + } + msg.append("\n"); + while (this.results.next()) { + for (int i = 1; i < md.getColumnCount() + 1; i++) { + msg.append(results.getString(i) + "\t"); + } + msg.append("\n"); + } + this.msg = msg.toString(); + } catch (SQLException ex) { + code = code.ERROR; + this.msg = ex.getMessage(); + } + return this.msg; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } +} diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/server/JsonResponse.java b/zeppelin-server/src/main/java/org/apache/zeppelin/server/JsonResponse.java index f8f1bdd95a9..6a26fec7ddd 100644 --- a/zeppelin-server/src/main/java/org/apache/zeppelin/server/JsonResponse.java +++ b/zeppelin-server/src/main/java/org/apache/zeppelin/server/JsonResponse.java @@ -24,6 +24,7 @@ import org.apache.zeppelin.interpreter.Interpreter; import org.apache.zeppelin.interpreter.InterpreterSerializer; +import org.apache.zeppelin.interpreter.InterpreterResult; import com.google.gson.Gson; import com.google.gson.GsonBuilder; diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/server/ZeppelinServer.java b/zeppelin-server/src/main/java/org/apache/zeppelin/server/ZeppelinServer.java index a6e944da8be..fafc6f962a6 100644 --- a/zeppelin-server/src/main/java/org/apache/zeppelin/server/ZeppelinServer.java +++ b/zeppelin-server/src/main/java/org/apache/zeppelin/server/ZeppelinServer.java @@ -33,6 +33,7 @@ import org.apache.zeppelin.conf.ZeppelinConfiguration; import org.apache.zeppelin.conf.ZeppelinConfiguration.ConfVars; import org.apache.zeppelin.interpreter.InterpreterFactory; +import org.apache.zeppelin.interpreter.ResultRepoFactory; import org.apache.zeppelin.notebook.Notebook; import org.apache.zeppelin.notebook.repo.NotebookRepo; import org.apache.zeppelin.notebook.repo.NotebookRepoSync; @@ -68,6 +69,8 @@ public class ZeppelinServer extends Application { private static final Logger LOG = LoggerFactory.getLogger(ZeppelinServer.class); private SchedulerFactory schedulerFactory; + private ResultRepoFactory resultRepoFactory; + public static Notebook notebook; public static NotebookServer notebookServer; @@ -252,8 +255,10 @@ public ZeppelinServer() throws Exception { this.schedulerFactory = new SchedulerFactory(); - this.replFactory = new InterpreterFactory(conf, notebookServer); + this.resultRepoFactory = new ResultRepoFactory(conf); + this.replFactory = new InterpreterFactory(conf, notebookServer, resultRepoFactory); this.notebookRepo = new NotebookRepoSync(conf); + notebook = new Notebook(conf, notebookRepo, schedulerFactory, replFactory, notebookServer); } diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/FilesystemResultRepo.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/FilesystemResultRepo.java new file mode 100644 index 00000000000..bac2f285351 --- /dev/null +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/FilesystemResultRepo.java @@ -0,0 +1,164 @@ +package org.apache.zeppelin.interpreter; + +import java.sql.ResultSet; +import org.apache.commons.vfs2.FileContent; +import org.apache.commons.vfs2.FileObject; +import org.apache.commons.vfs2.FileSystemManager; +import org.apache.commons.vfs2.FileType; +import org.apache.commons.vfs2.NameScope; +import org.apache.commons.vfs2.Selectors; +import org.apache.commons.vfs2.VFS; +import org.apache.zeppelin.conf.ZeppelinConfiguration; +import org.apache.zeppelin.conf.ZeppelinConfiguration.ConfVars; +import org.apache.commons.io.IOUtils; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.LinkedList; +import java.util.List; +import java.util.Properties; + +import javax.sql.rowset.CachedRowSet; + +import java.util.UUID; + +/** + * Store the results back into the filesystem. + * @author Rusty Phillips {@literal: } + * + */ +public class FilesystemResultRepo extends RemoteResultRepo { + static { + RemoteResultRepo.register("File System", FilesystemResultRepo.class.getName()); + } + private FileSystemManager fsManager; + private URI filesystemRoot; + + private Properties properties; + private ZeppelinConfiguration conf; + + public FilesystemResultRepo(ZeppelinConfiguration conf) throws IOException { + this.conf = conf; + + try { + filesystemRoot = new URI(conf.getNotebookDir() + "/_results"); + } catch (URISyntaxException e1) { + throw new IOException(e1); + } + + if (filesystemRoot.getScheme() == null) { // it is local path + try { + this.filesystemRoot = new URI(new File( + conf.getRelativeDir(filesystemRoot.getPath())).getAbsolutePath()); + } catch (URISyntaxException e) { + throw new IOException(e); + } + } else { + this.filesystemRoot = filesystemRoot; + } + fsManager = VFS.getManager(); + } + + private String getPath(String path) { + if (path == null || path.trim().length() == 0) { + return filesystemRoot.toString(); + } + if (path.startsWith("/")) { + return filesystemRoot.toString() + path; + } else { + return filesystemRoot.toString() + "/" + path; + } + } + + private boolean isDirectory(FileObject fo) throws IOException { + if (fo == null) return false; + if (fo.getType() == FileType.FOLDER) { + return true; + } else { + return false; + } + } + + private FileObject getRootDir() throws IOException { + FileObject rootDir = fsManager.resolveFile(getPath("/")); + + if (!rootDir.exists()) { + throw new IOException("Root path does not exists"); + } + + if (!isDirectory(rootDir)) { + throw new IOException("Root path is not a directory"); + } + + return rootDir; + } + + + + @Override + public String save(String result, String id) throws IOException { + removeResult(id); + + FileObject rootDir = getRootDir(); + FileObject resultDir = rootDir.resolveFile(id, NameScope.CHILD); + if (!resultDir.exists()) { + resultDir.createFolder(); + } + + if (!isDirectory(resultDir)) { + throw new IOException(resultDir.getName().toString() + " is not a directory"); + } + + FileObject resultJson = resultDir.resolveFile("result.txt", NameScope.CHILD); + // false means not appending. creates file if not exists + OutputStream out = resultJson.getContent().getOutputStream(false); + out.write(result.getBytes(conf.getString(ConfVars.ZEPPELIN_ENCODING))); + out.close(); + return id; + } + + private String getResult(FileObject resultDir) throws IOException { + FileObject resultJson = resultDir.resolveFile("result.txt", NameScope.CHILD); + if (!resultJson.exists()) { + throw new IOException(resultJson.getName().toString() + " not found"); + } + + FileContent content = resultJson.getContent(); + InputStream ins = content.getInputStream(); + String text = IOUtils.toString(ins, conf.getString(ConfVars.ZEPPELIN_ENCODING)); + ins.close(); + + return text; + } + + @Override + public void removeResult(String id) throws IOException { + FileObject rootDir = fsManager.resolveFile(getPath("/")); + FileObject resultDir = rootDir.resolveFile(id, NameScope.CHILD); + + if (!resultDir.exists()) { + // nothing to do + return; + } + + if (!isDirectory(resultDir)) { + // it is not look like zeppelin note savings + throw new IOException("Can not remove " + resultDir.getName().toString()); + } + + resultDir.delete(Selectors.SELECT_SELF_AND_CHILDREN); + } + + @Override + public String get(String id) throws IOException { + FileObject rootDir = fsManager.resolveFile(getPath("/")); + FileObject noteDir = rootDir.resolveFile(id, NameScope.CHILD); + + return getResult(noteDir); + } + +} diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterFactory.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterFactory.java index 8a1d6ff2752..5483af2f903 100644 --- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterFactory.java +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterFactory.java @@ -49,6 +49,8 @@ import org.apache.zeppelin.interpreter.Interpreter.RegisteredInterpreter; import org.apache.zeppelin.interpreter.remote.RemoteAngularObjectRegistry; import org.apache.zeppelin.interpreter.remote.RemoteInterpreter; +import org.apache.zeppelin.notebook.Paragraph; +import org.apache.zeppelin.notebook.ParagraphSerializer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -61,6 +63,17 @@ */ public class InterpreterFactory { Logger logger = LoggerFactory.getLogger(InterpreterFactory.class); + ResultRepoFactory resultRepoFactory; + + public ResultRepoFactory getResultRepoFactory() { + return resultRepoFactory; + } + + + public void setResultRepoFactory(ResultRepoFactory resultRepoFactory) { + this.resultRepoFactory = resultRepoFactory; + } + private Map cleanCl = Collections .synchronizedMap(new HashMap()); @@ -80,24 +93,28 @@ public class InterpreterFactory { AngularObjectRegistryListener angularObjectRegistryListener; public InterpreterFactory(ZeppelinConfiguration conf, - AngularObjectRegistryListener angularObjectRegistryListener) + AngularObjectRegistryListener angularObjectRegistryListener, + ResultRepoFactory resultrepo) throws InterpreterException, IOException { - this(conf, new InterpreterOption(true), angularObjectRegistryListener); + this(conf, new InterpreterOption(true), angularObjectRegistryListener, resultrepo); } public InterpreterFactory(ZeppelinConfiguration conf, InterpreterOption defaultOption, - AngularObjectRegistryListener angularObjectRegistryListener) + AngularObjectRegistryListener angularObjectRegistryListener, ResultRepoFactory resultrepo) throws InterpreterException, IOException { this.conf = conf; this.defaultOption = defaultOption; this.angularObjectRegistryListener = angularObjectRegistryListener; + this.resultRepoFactory = resultrepo; String replsConf = conf.getString(ConfVars.ZEPPELIN_INTERPRETERS); interpreterClassList = replsConf.split(","); GsonBuilder builder = new GsonBuilder(); builder.setPrettyPrinting(); builder.registerTypeAdapter(Interpreter.class, new InterpreterSerializer()); + /* builder.registerTypeAdapter(JdbcInterpreterResult.class, + new InterpreterResultSerializer(resultRepoFactory)); */ gson = builder.create(); init(); @@ -197,6 +214,7 @@ private void loadFromFile() throws IOException { GsonBuilder builder = new GsonBuilder(); builder.setPrettyPrinting(); builder.registerTypeAdapter(Interpreter.class, new InterpreterSerializer()); + builder.registerTypeAdapter(Paragraph.class, new ParagraphSerializer(resultRepoFactory)); Gson gson = builder.create(); File settingFile = new File(conf.getInterpreterSettingPath()); @@ -227,8 +245,6 @@ private void loadFromFile() throws IOException { // previously created setting should turn this feature on here. setting.getOption().setRemote(true); - - InterpreterSetting intpSetting = new InterpreterSetting( setting.id(), setting.getName(), @@ -248,7 +264,6 @@ private void loadFromFile() throws IOException { this.interpreterBindings = info.interpreterBindings; } - private void saveToFile() throws IOException { String jsonString; diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterResultSerializer.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterResultSerializer.java new file mode 100644 index 00000000000..618752e0f25 --- /dev/null +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterResultSerializer.java @@ -0,0 +1,82 @@ +package org.apache.zeppelin.interpreter; + +import java.io.IOException; +import java.lang.reflect.Field; +import java.lang.reflect.Type; +import java.sql.ResultSet; +import java.util.Map.Entry; + +import org.apache.zeppelin.interpreter.InterpreterResult.Code; + +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; + +/** + * Separates results from everything else. + * + * @author Rusty Phillips {@literal: } + * + */ +public class InterpreterResultSerializer + implements JsonSerializer, JsonDeserializer { + + RemoteResultRepo repo; + String id; + + public InterpreterResultSerializer() { + } + + public InterpreterResultSerializer(RemoteResultRepo repo, String ParagraphId) { + this.repo = repo; + this.id = ParagraphId; + } + + @Override + public InterpreterResult deserialize(JsonElement json, Type typeOfT, + JsonDeserializationContext context) + throws JsonParseException { + JsonObject object = json.getAsJsonObject(); + + String code = object.get("code").getAsString(); + String type = object.get("type").getAsString(); + InterpreterResult interpreterResult = new InterpreterResult(null); + + String result = null; + try { + for (Entry entry : object.entrySet()) { + try { + Field f; + f = InterpreterResult.class.getDeclaredField(entry.getKey()); + f.setAccessible(true); + f.set(interpreterResult, context.deserialize(entry.getValue(), f.getType())); + } catch (NoSuchFieldException ex) { + } + } + // Only fetch from the repo if it's not stored already. + if (interpreterResult.msg == null) + result = repo.get(id); + } catch (IOException | IllegalArgumentException | IllegalAccessException e) { + throw new JsonParseException(e.getMessage()); + } + return interpreterResult; + } + + @Override + public JsonElement serialize(InterpreterResult src, Type typeOfSrc, + JsonSerializationContext context) { + try { + JsonObject object = new JsonObject(); + repo.save(src.message(), id); + object.addProperty("code", src.code().toString()); + object.addProperty("type", src.type().toString()); + return object; + } catch (IOException ex) { + throw new JsonParseException(ex); + } + } +} diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/RemoteResultRepo.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/RemoteResultRepo.java new file mode 100644 index 00000000000..14484b71784 --- /dev/null +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/RemoteResultRepo.java @@ -0,0 +1,68 @@ +package org.apache.zeppelin.interpreter; + +import java.sql.ResultSet; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.net.URL; +import java.util.Properties; + +import javax.tools.FileObject; + +import org.apache.zeppelin.interpreter.Interpreter.RegisteredInterpreter; +import org.apache.commons.vfs2.FileType; +import org.apache.zeppelin.conf.ZeppelinConfiguration; +import org.apache.zeppelin.conf.ZeppelinConfiguration.ConfVars; + + +/** + * Describes how to save/load results. + * @author Rusty Phillips {@literal: } + * + */ +public class RemoteResultRepo { + protected Properties property; + + // TODO(Add Class loading): Make it so that result repositories load their classes. + private URL[] classloaderUrls; + + private RemoteResultRepo childRepo; + + public RemoteResultRepo() { + childRepo = null; + } + + public RemoteResultRepo(String ClassName, Properties props) throws ReflectiveOperationException { + if (!registeredRepos.containsValue(ClassName)) { + ClassName = registeredRepos.values().iterator().next(); + } + childRepo = (RemoteResultRepo) Class.forName(ClassName) + .getConstructor(new Class[] { Properties.class }).newInstance(props); + + } + + public URL[] getClassloaderUrls() { + return classloaderUrls; + } + + public void setClassloaderUrls(URL[] classloaderUrls) { + this.classloaderUrls = classloaderUrls; + } + + // Returns the thing that finds the result. + public String save(String result, String id) throws IOException + { return childRepo.save(result, id); } + public String get(String id) throws IOException { return childRepo.get(id); } + public void removeResult(String id) throws IOException { childRepo.removeResult(id); } + + public static Map registeredRepos = + Collections.synchronizedMap(new HashMap()); + + public static void register(String name, String repoClass) { + registeredRepos.put(name, repoClass); + } +} + diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/ResultRepoFactory.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/ResultRepoFactory.java new file mode 100644 index 00000000000..2b8314ade92 --- /dev/null +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/ResultRepoFactory.java @@ -0,0 +1,62 @@ +package org.apache.zeppelin.interpreter; + +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; + +import org.apache.zeppelin.conf.ZeppelinConfiguration; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import java.util.Map; + +import javax.management.ReflectionException; + +import java.util.HashMap; +import java.util.Collections; +/** + * Keeps track of the different varieties of result repositories. + * @author Rusty Phillips {@literal: } + * + */ +public class ResultRepoFactory { + Logger logger = LoggerFactory.getLogger(ResultRepoFactory.class); + private ZeppelinConfiguration conf; + + private Map repos = Collections + .synchronizedMap(new HashMap()); + + public ResultRepoFactory(ZeppelinConfiguration conf) + throws IOException, ReflectiveOperationException { + this.conf = conf; + for (String className: RemoteResultRepo.registeredRepos.values()) { + repos.put(className, (RemoteResultRepo) + Class.forName(className).getConstructor( + new Class[] {ZeppelinConfiguration.class }).newInstance(conf)); + } + } + + public RemoteResultRepo getDefaultRepo() throws IOException + { + return getRepoByClassName("org.apache.zeppelin.interpreter.FilesystemResultRepo"); + } + + public RemoteResultRepo getRepoByClassName(String className) + throws IOException { + if (repos.containsKey(className)) + return repos.get(className); + try { + ClassLoader cl = ClassLoader.getSystemClassLoader(); + cl.loadClass(className); + return repos.put(className, (RemoteResultRepo) + Class.forName(className).getConstructor( + new Class[] {ZeppelinConfiguration.class }).newInstance(conf) ); + + } catch (ClassNotFoundException | NoSuchMethodException | SecurityException + | InstantiationException | IllegalAccessException + | IllegalArgumentException | InvocationTargetException e) { + e.printStackTrace(); + throw new IOException(e); + } + } + + +} diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/NoteInterpreterLoader.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/NoteInterpreterLoader.java index 509a064ab63..cda21123c5e 100644 --- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/NoteInterpreterLoader.java +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/NoteInterpreterLoader.java @@ -18,6 +18,7 @@ package org.apache.zeppelin.notebook; import java.io.IOException; +import java.rmi.Remote; import java.util.LinkedList; import java.util.List; @@ -27,6 +28,8 @@ import org.apache.zeppelin.interpreter.InterpreterFactory; import org.apache.zeppelin.interpreter.InterpreterGroup; import org.apache.zeppelin.interpreter.InterpreterSetting; +import org.apache.zeppelin.interpreter.RemoteResultRepo; +import org.apache.zeppelin.interpreter.ResultRepoFactory; /** * Repl loader per note. @@ -39,6 +42,10 @@ public NoteInterpreterLoader(InterpreterFactory factory) { this.factory = factory; } + public ResultRepoFactory getResultFactory() { + return factory.getResultRepoFactory(); + } + public void setNoteId(String noteId) { this.noteId = noteId; } @@ -147,4 +154,5 @@ public Interpreter get(String replName) { throw new InterpreterException(replName + " interpreter not found"); } + } diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Notebook.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Notebook.java index 770172a43c3..efc74729e1b 100644 --- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Notebook.java +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Notebook.java @@ -35,6 +35,7 @@ import org.apache.zeppelin.interpreter.InterpreterFactory; import org.apache.zeppelin.interpreter.InterpreterGroup; import org.apache.zeppelin.interpreter.InterpreterSetting; +import org.apache.zeppelin.interpreter.ResultRepoFactory; import org.apache.zeppelin.interpreter.remote.RemoteAngularObjectRegistry; import org.apache.zeppelin.notebook.repo.NotebookRepo; import org.apache.zeppelin.scheduler.SchedulerFactory; @@ -58,6 +59,7 @@ public class Notebook { Logger logger = LoggerFactory.getLogger(Notebook.class); private SchedulerFactory schedulerFactory; private InterpreterFactory replFactory; + /** Keep the order. */ Map notes = new LinkedHashMap(); private ZeppelinConfiguration conf; @@ -67,8 +69,9 @@ public class Notebook { private NotebookRepo notebookRepo; public Notebook(ZeppelinConfiguration conf, NotebookRepo notebookRepo, - SchedulerFactory schedulerFactory, - InterpreterFactory replFactory, JobListenerFactory jobListenerFactory) throws IOException, + SchedulerFactory schedulerFactory, InterpreterFactory replFactory, + JobListenerFactory jobListenerFactory) + throws IOException, SchedulerException { this.conf = conf; this.notebookRepo = notebookRepo; @@ -218,7 +221,7 @@ private Note loadNoteFromRepo(String id) { // set NoteInterpreterLoader NoteInterpreterLoader noteInterpreterLoader = new NoteInterpreterLoader( - replFactory); + replFactory); note.setReplLoader(noteInterpreterLoader); noteInterpreterLoader.setNoteId(note.id()); diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Paragraph.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Paragraph.java index fc3646aaf57..30fbe604095 100644 --- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Paragraph.java +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Paragraph.java @@ -27,6 +27,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.IOException; import java.io.Serializable; import java.util.*; @@ -43,8 +44,9 @@ public class Paragraph extends Job implements Serializable, Cloneable { String title; String text; Date dateUpdated; - private Map config; // paragraph configs like isOpen, colWidth, etc - public final GUI settings; // form and parameter settings + private Map config; // paragraph configs like isOpen, + // colWidth, etc + public final GUI settings; // form and parameter settings public Paragraph(Note note, JobListener listener, NoteInterpreterLoader replLoader) { super(generateId(), listener); @@ -55,11 +57,14 @@ public Paragraph(Note note, JobListener listener, NoteInterpreterLoader replLoad dateUpdated = null; settings = new GUI(); config = new HashMap(); + config.put("RESULT_REPO", + "org.apache.zeppelin.interpreter.FilesystemResultRepo"); + //replLoader.getResultFactory().getDefaultRepo().getClass().getName()); } private static String generateId() { - return "paragraph_" + System.currentTimeMillis() + "_" - + new Random(System.currentTimeMillis()).nextInt(); + return "paragraph_" + System.currentTimeMillis() + + "_" + new Random(System.currentTimeMillis()).nextInt(); } public String getText() { @@ -71,7 +76,6 @@ public void setText(String newText) { this.dateUpdated = new Date(); } - public String getTitle() { return title; } @@ -118,6 +122,7 @@ public static String getRequiredReplName(String text) { } private String getScriptBody() { + return getScriptBody(text); } @@ -198,12 +203,19 @@ protected Object jobRun() throws Throwable { settings.clear(); } else if (repl.getFormType() == FormType.SIMPLE) { String scriptBody = getScriptBody(); - Map inputs = Input.extractSimpleQueryParam(scriptBody); // inputs will be built - // from script body + Map inputs = Input.extractSimpleQueryParam(scriptBody); // inputs + // will + // be + // built + // from + // script + // body settings.setForms(inputs); script = Input.getSimpleQuery(settings.getParams(), scriptBody); } logger().debug("RUN : " + script); + // Delete existing result before setting new one. + InterpreterResult ret = repl.interpret(script, getInterpreterContext()); return ret; } @@ -228,15 +240,9 @@ private InterpreterContext getInterpreterContext() { runners.add(new ParagraphRunner(note, note.id(), p.getId())); } - InterpreterContext interpreterContext = new InterpreterContext( - note.id(), - getId(), - this.getTitle(), - this.getText(), - this.getConfig(), - this.settings, - registry, - runners); + InterpreterContext interpreterContext = new InterpreterContext + (note.id(), getId(), this.getTitle(), this.getText(), + this.getConfig(), this.settings, registry, runners); return interpreterContext; } @@ -254,13 +260,11 @@ public void run() { } } - private Logger logger() { Logger logger = LoggerFactory.getLogger(Paragraph.class); return logger; } - public Map getConfig() { return config; } diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/ParagraphSerializer.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/ParagraphSerializer.java new file mode 100644 index 00000000000..1dfa9e5b41a --- /dev/null +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/ParagraphSerializer.java @@ -0,0 +1,117 @@ +package org.apache.zeppelin.notebook; + +import java.io.IOException; +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; +import org.apache.commons.lang3.reflect.FieldUtils; +import javax.naming.spi.DirStateFactory.Result; +import org.apache.zeppelin.interpreter.FilesystemResultRepo; + +import org.apache.zeppelin.interpreter.InterpreterResult; +import org.apache.zeppelin.interpreter.InterpreterResultSerializer; +import org.apache.zeppelin.interpreter.ResultRepoFactory; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; + +/** + * Serializes paragraphs. + * @author Rusty Phillips {@literal: } + * + */ +public class ParagraphSerializer implements JsonSerializer, JsonDeserializer { + + private ResultRepoFactory factory; + + public ParagraphSerializer(ResultRepoFactory factory) { + this.factory = factory; + } + + private static String getResultRepo(JsonElement json) + { + JsonElement repo = json.getAsJsonObject().get("config").getAsJsonObject().get("RESULT_REPO"); + if (repo == null) + return null; + return repo.getAsString(); + } + + @Override + public Paragraph deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) + throws JsonParseException { + try { + Paragraph p = new Paragraph(null, null, null); + // p = context.deserialize(json, typeOfT); + Field[] fields = Paragraph.class.getFields(); + String resultRepo = getResultRepo(json); + JsonObject object = json.getAsJsonObject(); + GsonBuilder builder = new GsonBuilder(); + String id = object.get("id").getAsString(); + + builder.setPrettyPrinting(); + if (resultRepo != null && factory != null) { + builder.registerTypeAdapter(InterpreterResult.class, + new InterpreterResultSerializer(factory.getRepoByClassName(resultRepo), id)); + } + Gson gson = builder.create(); + for (Entry entry: object.entrySet()) { + try { + Field f; + f = Paragraph.class.getDeclaredField(entry.getKey()); + f.setAccessible(true); + f.set(p, gson.fromJson(entry.getValue(), f.getType())); + } catch (NoSuchFieldException e) { + // If the paragraph format has changed, we do not want to do anything + // with the fields that are extraneous. + } + + } + return p; + } catch (SecurityException | IllegalArgumentException | IllegalAccessException | IOException ex) + { throw new JsonParseException(ex); } + + } + + + @Override + public JsonElement serialize(Paragraph src, Type typeOfSrc, JsonSerializationContext context) { + try { + Field[] fields = FieldUtils.getAllFields(Paragraph.class); + GsonBuilder builder = new GsonBuilder(); + JsonObject object = new JsonObject(); + Boolean serializeResult = src.getConfig().containsKey("RESULT_REPO") && factory != null; + if (serializeResult) { + builder.registerTypeAdapter(InterpreterResult.class, + new InterpreterResultSerializer( + factory.getRepoByClassName(src.getConfig().get("RESULT_REPO").toString()), + src.getId())); + } + + Gson gson = builder.create(); + + for (Field f: fields) + { + if ((f.getModifiers() & (Modifier.TRANSIENT | Modifier.STATIC | Modifier.VOLATILE)) == 0 ) + { + f.setAccessible(true); + object.add(f.getName(), gson.toJsonTree(f.get(src), f.getType())); + } + } + + return object; + } catch + (SecurityException | IllegalArgumentException | IllegalAccessException | IOException ex ) + { throw new JsonParseException(ex); } + } + +} diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/S3NotebookRepo.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/S3NotebookRepo.java index bb9e5d1571d..d8a6d4c4f3a 100644 --- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/S3NotebookRepo.java +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/S3NotebookRepo.java @@ -29,9 +29,11 @@ import org.apache.commons.io.IOUtils; import org.apache.zeppelin.conf.ZeppelinConfiguration; import org.apache.zeppelin.conf.ZeppelinConfiguration.ConfVars; +import org.apache.zeppelin.interpreter.ResultRepoFactory; import org.apache.zeppelin.notebook.Note; import org.apache.zeppelin.notebook.NoteInfo; import org.apache.zeppelin.notebook.Paragraph; +import org.apache.zeppelin.notebook.ParagraphSerializer; import org.apache.zeppelin.scheduler.Job.Status; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -78,13 +80,19 @@ public class S3NotebookRepo implements NotebookRepo { private static String bucketName = ""; private String user = ""; - + private ResultRepoFactory factory; private ZeppelinConfiguration conf; public S3NotebookRepo(ZeppelinConfiguration conf) throws IOException { this.conf = conf; user = conf.getUser(); + try { + factory = new ResultRepoFactory(conf); + } catch (ReflectiveOperationException e) { + throw new IOException(e); + } + bucketName = conf.getBucketName(); } @@ -132,8 +140,8 @@ public List list() throws IOException { private Note getNote(String key) throws IOException { GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.setPrettyPrinting(); + gsonBuilder.registerTypeAdapter(Paragraph.class, new ParagraphSerializer(factory)); Gson gson = gsonBuilder.create(); - S3Object s3object = s3client.getObject(new GetObjectRequest( bucketName, key)); @@ -164,6 +172,7 @@ public Note get(String noteId) throws IOException { public void save(Note note) throws IOException { GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.setPrettyPrinting(); + gsonBuilder.registerTypeAdapter(Paragraph.class, new ParagraphSerializer(factory)); Gson gson = gsonBuilder.create(); String json = gson.toJson(note); String key = user + "/" + "notebook" + "/" + note.id() + "/" + "note.json"; diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/VFSNotebookRepo.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/VFSNotebookRepo.java index 3039f80ff7d..5ab835ff5f6 100644 --- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/VFSNotebookRepo.java +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/VFSNotebookRepo.java @@ -36,9 +36,11 @@ import org.apache.commons.vfs2.VFS; import org.apache.zeppelin.conf.ZeppelinConfiguration; import org.apache.zeppelin.conf.ZeppelinConfiguration.ConfVars; +import org.apache.zeppelin.interpreter.ResultRepoFactory; import org.apache.zeppelin.notebook.Note; import org.apache.zeppelin.notebook.NoteInfo; import org.apache.zeppelin.notebook.Paragraph; +import org.apache.zeppelin.notebook.ParagraphSerializer; import org.apache.zeppelin.scheduler.Job.Status; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -56,7 +58,8 @@ public class VFSNotebookRepo implements NotebookRepo { private URI filesystemRoot; private ZeppelinConfiguration conf; - + private ResultRepoFactory factory; + public VFSNotebookRepo(ZeppelinConfiguration conf) throws IOException { this.conf = conf; @@ -77,6 +80,13 @@ public VFSNotebookRepo(ZeppelinConfiguration conf) throws IOException { this.filesystemRoot = filesystemRoot; } fsManager = VFS.getManager(); + + try { + factory = new ResultRepoFactory(conf); + } catch (ReflectiveOperationException e) { + throw new IOException(e); + } + } private String getPath(String path) { @@ -148,6 +158,8 @@ private Note getNote(FileObject noteDir) throws IOException { } GsonBuilder gsonBuilder = new GsonBuilder(); + gsonBuilder.registerTypeAdapter(Paragraph.class, new ParagraphSerializer(factory)); + gsonBuilder.setPrettyPrinting(); Gson gson = gsonBuilder.create(); @@ -199,6 +211,7 @@ private FileObject getRootDir() throws IOException { @Override public void save(Note note) throws IOException { GsonBuilder gsonBuilder = new GsonBuilder(); + gsonBuilder.registerTypeAdapter(Paragraph.class, new ParagraphSerializer(factory)); gsonBuilder.setPrettyPrinting(); Gson gson = gsonBuilder.create(); String json = gson.toJson(note); From 828a67df32036f16ee25089a68a9b97dd6db1406 Mon Sep 17 00:00:00 2001 From: Rusty Phillips Date: Thu, 5 Nov 2015 15:28:03 -0500 Subject: [PATCH 2/3] Removed Hive interpreter parts. --- .../zeppelin/hive/ForgivingHiveResultSet.java | 828 ------------------ .../hive/ForgivingHiveResultSetMetadata.java | 111 --- .../apache/zeppelin/hive/HiveInterpreter.java | 4 - 3 files changed, 943 deletions(-) delete mode 100644 hive/src/main/java/org/apache/zeppelin/hive/ForgivingHiveResultSet.java delete mode 100644 hive/src/main/java/org/apache/zeppelin/hive/ForgivingHiveResultSetMetadata.java diff --git a/hive/src/main/java/org/apache/zeppelin/hive/ForgivingHiveResultSet.java b/hive/src/main/java/org/apache/zeppelin/hive/ForgivingHiveResultSet.java deleted file mode 100644 index 30633d26c49..00000000000 --- a/hive/src/main/java/org/apache/zeppelin/hive/ForgivingHiveResultSet.java +++ /dev/null @@ -1,828 +0,0 @@ -package org.apache.zeppelin.hive; - -import org.apache.hive.jdbc.HiveQueryResultSet; - -import java.io.InputStream; -import java.io.Reader; -import java.math.BigDecimal; -import java.net.URL; -import java.sql.Array; -import java.sql.Blob; -import java.sql.Clob; -import java.sql.Date; -import java.sql.NClob; -import java.sql.Ref; -import java.sql.ResultSet; -import java.sql.ResultSetMetaData; -import java.sql.RowId; -import java.sql.SQLException; -import java.sql.SQLType; -import java.sql.SQLWarning; -import java.sql.SQLXML; -import java.sql.Statement; -import java.sql.Time; -import java.sql.Timestamp; -import java.util.Calendar; -import java.util.Map; -/** - * Overwrites the not supported Hive methods with ones that say - * that a column doesn't have a given feature. - * This allows hive to work properly with cached result sets. - * - * @author Rusty Phillips {@literal: } - * - */ -public class ForgivingHiveResultSet implements ResultSet { - ResultSet inner_results; - - public int hashCode() { - return inner_results.hashCode(); - } - - public boolean absolute(int row) throws SQLException { - return inner_results.absolute(row); - } - - public void afterLast() throws SQLException { - inner_results.afterLast(); - } - - public void cancelRowUpdates() throws SQLException { - inner_results.cancelRowUpdates(); - } - - public void deleteRow() throws SQLException { - inner_results.deleteRow(); - } - - public int findColumn(String columnName) throws SQLException { - return inner_results.findColumn(columnName); - } - - public boolean first() throws SQLException { - return inner_results.first(); - } - - public Array getArray(int i) throws SQLException { - return inner_results.getArray(i); - } - - public Array getArray(String colName) throws SQLException { - return inner_results.getArray(colName); - } - - public InputStream getAsciiStream(int columnIndex) throws SQLException { - return inner_results.getAsciiStream(columnIndex); - } - - public InputStream getAsciiStream(String columnName) throws SQLException { - return inner_results.getAsciiStream(columnName); - } - - public boolean equals(Object obj) { - return inner_results.equals(obj); - } - - public BigDecimal getBigDecimal(int columnIndex) throws SQLException { - return inner_results.getBigDecimal(columnIndex); - } - - public BigDecimal getBigDecimal(String columnName) throws SQLException { - return inner_results.getBigDecimal(columnName); - } - - public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException { - return inner_results.getBigDecimal(columnIndex, scale); - } - - public BigDecimal getBigDecimal(String columnName, int scale) throws SQLException { - return inner_results.getBigDecimal(columnName, scale); - } - - public InputStream getBinaryStream(int columnIndex) throws SQLException { - return inner_results.getBinaryStream(columnIndex); - } - - public InputStream getBinaryStream(String columnName) throws SQLException { - return inner_results.getBinaryStream(columnName); - } - - public Blob getBlob(int i) throws SQLException { - return inner_results.getBlob(i); - } - - public Blob getBlob(String colName) throws SQLException { - return inner_results.getBlob(colName); - } - - public boolean getBoolean(int columnIndex) throws SQLException { - return inner_results.getBoolean(columnIndex); - } - - public boolean getBoolean(String columnName) throws SQLException { - return inner_results.getBoolean(columnName); - } - - public byte getByte(int columnIndex) throws SQLException { - return inner_results.getByte(columnIndex); - } - - public byte getByte(String columnName) throws SQLException { - return inner_results.getByte(columnName); - } - - public byte[] getBytes(int columnIndex) throws SQLException { - return inner_results.getBytes(columnIndex); - } - - public byte[] getBytes(String columnName) throws SQLException { - return inner_results.getBytes(columnName); - } - - public Reader getCharacterStream(int columnIndex) throws SQLException { - return inner_results.getCharacterStream(columnIndex); - } - - public Reader getCharacterStream(String columnName) throws SQLException { - return inner_results.getCharacterStream(columnName); - } - - public Clob getClob(int i) throws SQLException { - return inner_results.getClob(i); - } - - public Clob getClob(String colName) throws SQLException { - return inner_results.getClob(colName); - } - - public int getConcurrency() throws SQLException { - return inner_results.getConcurrency(); - } - - public String getCursorName() throws SQLException { - return inner_results.getCursorName(); - } - - public Date getDate(int columnIndex) throws SQLException { - return inner_results.getDate(columnIndex); - } - - public Date getDate(String columnName) throws SQLException { - return inner_results.getDate(columnName); - } - - public Date getDate(int columnIndex, Calendar cal) throws SQLException { - return inner_results.getDate(columnIndex, cal); - } - - public Date getDate(String columnName, Calendar cal) throws SQLException { - return inner_results.getDate(columnName, cal); - } - - public double getDouble(int columnIndex) throws SQLException { - return inner_results.getDouble(columnIndex); - } - - public double getDouble(String columnName) throws SQLException { - return inner_results.getDouble(columnName); - } - - public int getFetchDirection() throws SQLException { - return inner_results.getFetchDirection(); - } - - public String toString() { - return inner_results.toString(); - } - - public float getFloat(int columnIndex) throws SQLException { - return inner_results.getFloat(columnIndex); - } - - public float getFloat(String columnName) throws SQLException { - return inner_results.getFloat(columnName); - } - - public int getHoldability() throws SQLException { - return inner_results.getHoldability(); - } - - public int getInt(int columnIndex) throws SQLException { - return inner_results.getInt(columnIndex); - } - - public int getInt(String columnName) throws SQLException { - return inner_results.getInt(columnName); - } - - public long getLong(int columnIndex) throws SQLException { - return inner_results.getLong(columnIndex); - } - - public void close() throws SQLException { - inner_results.close(); - } - - public boolean next() throws SQLException { - return inner_results.next(); - } - - public long getLong(String columnName) throws SQLException { - return inner_results.getLong(columnName); - } - - public Reader getNCharacterStream(int arg0) throws SQLException { - return inner_results.getNCharacterStream(arg0); - } - - public Reader getNCharacterStream(String arg0) throws SQLException { - return inner_results.getNCharacterStream(arg0); - } - - public NClob getNClob(int arg0) throws SQLException { - return inner_results.getNClob(arg0); - } - - public NClob getNClob(String columnLabel) throws SQLException { - return inner_results.getNClob(columnLabel); - } - - public String getNString(int columnIndex) throws SQLException { - return inner_results.getNString(columnIndex); - } - - public String getNString(String columnLabel) throws SQLException { - return inner_results.getNString(columnLabel); - } - - public ResultSetMetaData getMetaData() throws SQLException { - return new ForgivingHiveResultSetMetadata(inner_results.getMetaData()); - } - - public void setFetchSize(int rows) throws SQLException { - inner_results.setFetchSize(rows); - } - - public int getType() throws SQLException { - return inner_results.getType(); - } - - public Object getObject(int columnIndex) throws SQLException { - return inner_results.getObject(columnIndex); - } - - public int getFetchSize() throws SQLException { - return inner_results.getFetchSize(); - } - - public Object getObject(String columnName) throws SQLException { - return inner_results.getObject(columnName); - } - - public Object getObject(int i, Map> map) throws SQLException { - return inner_results.getObject(i, map); - } - - public T getObject(String columnLabel, Class type) throws SQLException { - return inner_results.getObject(columnLabel, type); - } - - public Object getObject(String colName, Map> map) throws SQLException { - return inner_results.getObject(colName, map); - } - - public T getObject(int columnIndex, Class type) throws SQLException { - return inner_results.getObject(columnIndex, type); - } - - public Ref getRef(int i) throws SQLException { - return inner_results.getRef(i); - } - - public void beforeFirst() throws SQLException { - inner_results.beforeFirst(); - } - - public Ref getRef(String colName) throws SQLException { - return inner_results.getRef(colName); - } - - public RowId getRowId(int columnIndex) throws SQLException { - return inner_results.getRowId(columnIndex); - } - - public RowId getRowId(String columnLabel) throws SQLException { - return inner_results.getRowId(columnLabel); - } - - public boolean isBeforeFirst() throws SQLException { - return inner_results.isBeforeFirst(); - } - - public SQLXML getSQLXML(int columnIndex) throws SQLException { - return inner_results.getSQLXML(columnIndex); - } - - public SQLXML getSQLXML(String columnLabel) throws SQLException { - return inner_results.getSQLXML(columnLabel); - } - - public int getRow() throws SQLException { - return inner_results.getRow(); - } - - public short getShort(int columnIndex) throws SQLException { - return inner_results.getShort(columnIndex); - } - - public short getShort(String columnName) throws SQLException { - return inner_results.getShort(columnName); - } - - public Statement getStatement() throws SQLException { - return inner_results.getStatement(); - } - - public String getString(int columnIndex) throws SQLException { - return inner_results.getString(columnIndex); - } - - public String getString(String columnName) throws SQLException { - return inner_results.getString(columnName); - } - - public Time getTime(int columnIndex) throws SQLException { - return inner_results.getTime(columnIndex); - } - - public Time getTime(String columnName) throws SQLException { - return inner_results.getTime(columnName); - } - - public Time getTime(int columnIndex, Calendar cal) throws SQLException { - return inner_results.getTime(columnIndex, cal); - } - - public Time getTime(String columnName, Calendar cal) throws SQLException { - return inner_results.getTime(columnName, cal); - } - - public Timestamp getTimestamp(int columnIndex) throws SQLException { - return inner_results.getTimestamp(columnIndex); - } - - public Timestamp getTimestamp(String columnName) throws SQLException { - return inner_results.getTimestamp(columnName); - } - - public Timestamp getTimestamp(int columnIndex, Calendar cal) throws SQLException { - return inner_results.getTimestamp(columnIndex, cal); - } - - public Timestamp getTimestamp(String columnName, Calendar cal) throws SQLException { - return inner_results.getTimestamp(columnName, cal); - } - - public URL getURL(int columnIndex) throws SQLException { - return inner_results.getURL(columnIndex); - } - - public URL getURL(String columnName) throws SQLException { - return inner_results.getURL(columnName); - } - - public InputStream getUnicodeStream(int columnIndex) throws SQLException { - return inner_results.getUnicodeStream(columnIndex); - } - - public InputStream getUnicodeStream(String columnName) throws SQLException { - return inner_results.getUnicodeStream(columnName); - } - - public void insertRow() throws SQLException { - inner_results.insertRow(); - } - - public boolean isAfterLast() throws SQLException { - return inner_results.isAfterLast(); - } - - public boolean isClosed() throws SQLException { - return inner_results.isClosed(); - } - - public boolean isFirst() throws SQLException { - return inner_results.isFirst(); - } - - public boolean isLast() throws SQLException { - return inner_results.isLast(); - } - - public boolean last() throws SQLException { - return inner_results.last(); - } - - public void moveToCurrentRow() throws SQLException { - inner_results.moveToCurrentRow(); - } - - public void moveToInsertRow() throws SQLException { - inner_results.moveToInsertRow(); - } - - public boolean previous() throws SQLException { - return inner_results.previous(); - } - - public void refreshRow() throws SQLException { - inner_results.refreshRow(); - } - - public boolean relative(int rows) throws SQLException { - return inner_results.relative(rows); - } - - public boolean rowDeleted() throws SQLException { - return inner_results.rowDeleted(); - } - - public boolean rowInserted() throws SQLException { - return inner_results.rowInserted(); - } - - public boolean rowUpdated() throws SQLException { - return inner_results.rowUpdated(); - } - - public void setFetchDirection(int direction) throws SQLException { - inner_results.setFetchDirection(direction); - } - - public void updateArray(int columnIndex, Array x) throws SQLException { - inner_results.updateArray(columnIndex, x); - } - - public void updateArray(String columnName, Array x) throws SQLException { - inner_results.updateArray(columnName, x); - } - - public void updateAsciiStream(int columnIndex, InputStream x) throws SQLException { - inner_results.updateAsciiStream(columnIndex, x); - } - - public void updateAsciiStream(String columnLabel, InputStream x) throws SQLException { - inner_results.updateAsciiStream(columnLabel, x); - } - - public void updateAsciiStream(int columnIndex, InputStream x, int length) throws SQLException { - inner_results.updateAsciiStream(columnIndex, x, length); - } - - public void updateAsciiStream(String columnName, InputStream x, int length) throws SQLException { - inner_results.updateAsciiStream(columnName, x, length); - } - - public void updateAsciiStream(int columnIndex, InputStream x, long length) throws SQLException { - inner_results.updateAsciiStream(columnIndex, x, length); - } - - public void updateAsciiStream(String columnLabel, - InputStream x, - long length) throws SQLException { - inner_results.updateAsciiStream(columnLabel, x, length); - } - - public void updateBigDecimal(int columnIndex, BigDecimal x) throws SQLException { - inner_results.updateBigDecimal(columnIndex, x); - } - - public void updateBigDecimal(String columnName, BigDecimal x) throws SQLException { - inner_results.updateBigDecimal(columnName, x); - } - - public void updateBinaryStream(int columnIndex, InputStream x) throws SQLException { - inner_results.updateBinaryStream(columnIndex, x); - } - - public void updateBinaryStream(String columnLabel, InputStream x) throws SQLException { - inner_results.updateBinaryStream(columnLabel, x); - } - - public void updateBinaryStream(int columnIndex, InputStream x, int length) throws SQLException { - inner_results.updateBinaryStream(columnIndex, x, length); - } - - public void updateBinaryStream(String columnName, InputStream x, int length) throws SQLException { - inner_results.updateBinaryStream(columnName, x, length); - } - - public void updateBinaryStream(int columnIndex, InputStream x, long length) throws SQLException { - inner_results.updateBinaryStream(columnIndex, x, length); - } - - public void updateBinaryStream(String columnLabel, - InputStream x, long length) throws SQLException { - inner_results.updateBinaryStream(columnLabel, x, length); - } - - public void updateBlob(int columnIndex, Blob x) throws SQLException { - inner_results.updateBlob(columnIndex, x); - } - - public void updateBlob(String columnName, Blob x) throws SQLException { - inner_results.updateBlob(columnName, x); - } - - public void updateBlob(int columnIndex, InputStream inputStream) throws SQLException { - inner_results.updateBlob(columnIndex, inputStream); - } - - public void updateBlob(String columnLabel, InputStream inputStream) throws SQLException { - inner_results.updateBlob(columnLabel, inputStream); - } - - public void updateBlob(int columnIndex, InputStream inputStream, long length) - throws SQLException { - inner_results.updateBlob(columnIndex, inputStream, length); - } - - public void updateBlob(String columnLabel, InputStream inputStream, long length) - throws SQLException { - inner_results.updateBlob(columnLabel, inputStream, length); - } - - public void updateBoolean(int columnIndex, boolean x) throws SQLException { - inner_results.updateBoolean(columnIndex, x); - } - - public void updateBoolean(String columnName, boolean x) throws SQLException { - inner_results.updateBoolean(columnName, x); - } - - public void updateByte(int columnIndex, byte x) throws SQLException { - inner_results.updateByte(columnIndex, x); - } - - public void updateByte(String columnName, byte x) throws SQLException { - inner_results.updateByte(columnName, x); - } - - public void updateBytes(int columnIndex, byte[] x) throws SQLException { - inner_results.updateBytes(columnIndex, x); - } - - public void updateBytes(String columnName, byte[] x) throws SQLException { - inner_results.updateBytes(columnName, x); - } - - public void updateCharacterStream(int columnIndex, Reader x) throws SQLException { - inner_results.updateCharacterStream(columnIndex, x); - } - - public void updateCharacterStream(String columnLabel, Reader reader) throws SQLException { - inner_results.updateCharacterStream(columnLabel, reader); - } - - public void updateCharacterStream(int columnIndex, Reader x, int length) throws SQLException { - inner_results.updateCharacterStream(columnIndex, x, length); - } - - public void updateCharacterStream(String columnName, Reader reader, int length) - throws SQLException { - inner_results.updateCharacterStream(columnName, reader, length); - } - - public void updateCharacterStream(int columnIndex, Reader x, long length) throws SQLException { - inner_results.updateCharacterStream(columnIndex, x, length); - } - - public void updateCharacterStream(String columnLabel, Reader reader, long length) - throws SQLException { - inner_results.updateCharacterStream(columnLabel, reader, length); - } - - public void updateClob(int columnIndex, Clob x) throws SQLException { - inner_results.updateClob(columnIndex, x); - } - - public void updateClob(String columnName, Clob x) throws SQLException { - inner_results.updateClob(columnName, x); - } - - public void updateClob(int columnIndex, Reader reader) throws SQLException { - inner_results.updateClob(columnIndex, reader); - } - - public void updateClob(String columnLabel, Reader reader) throws SQLException { - inner_results.updateClob(columnLabel, reader); - } - - public void updateClob(int columnIndex, Reader reader, long length) throws SQLException { - inner_results.updateClob(columnIndex, reader, length); - } - - public void updateClob(String columnLabel, Reader reader, long length) throws SQLException { - inner_results.updateClob(columnLabel, reader, length); - } - - public void updateDate(int columnIndex, Date x) throws SQLException { - inner_results.updateDate(columnIndex, x); - } - - public void updateDate(String columnName, Date x) throws SQLException { - inner_results.updateDate(columnName, x); - } - - public void updateDouble(int columnIndex, double x) throws SQLException { - inner_results.updateDouble(columnIndex, x); - } - - public void updateDouble(String columnName, double x) throws SQLException { - inner_results.updateDouble(columnName, x); - } - - public void updateFloat(int columnIndex, float x) throws SQLException { - inner_results.updateFloat(columnIndex, x); - } - - public void updateFloat(String columnName, float x) throws SQLException { - inner_results.updateFloat(columnName, x); - } - - public void updateInt(int columnIndex, int x) throws SQLException { - inner_results.updateInt(columnIndex, x); - } - - public void updateInt(String columnName, int x) throws SQLException { - inner_results.updateInt(columnName, x); - } - - public void updateLong(int columnIndex, long x) throws SQLException { - inner_results.updateLong(columnIndex, x); - } - - public void updateLong(String columnName, long x) throws SQLException { - inner_results.updateLong(columnName, x); - } - - public void updateNCharacterStream(int columnIndex, Reader x) throws SQLException { - inner_results.updateNCharacterStream(columnIndex, x); - } - - public void updateNCharacterStream(String columnLabel, Reader reader) throws SQLException { - inner_results.updateNCharacterStream(columnLabel, reader); - } - - public void updateNCharacterStream(int columnIndex, Reader x, long length) throws SQLException { - inner_results.updateNCharacterStream(columnIndex, x, length); - } - - public void updateNCharacterStream(String columnLabel, Reader reader, long length) - throws SQLException { - inner_results.updateNCharacterStream(columnLabel, reader, length); - } - - public void updateNClob(int columnIndex, NClob clob) throws SQLException { - inner_results.updateNClob(columnIndex, clob); - } - - public void updateNClob(String columnLabel, NClob clob) throws SQLException { - inner_results.updateNClob(columnLabel, clob); - } - - public void updateNClob(int columnIndex, Reader reader) throws SQLException { - inner_results.updateNClob(columnIndex, reader); - } - - public void updateNClob(String columnLabel, Reader reader) throws SQLException { - inner_results.updateNClob(columnLabel, reader); - } - - public void updateNClob(int columnIndex, Reader reader, long length) throws SQLException { - inner_results.updateNClob(columnIndex, reader, length); - } - - public void updateNClob(String columnLabel, Reader reader, long length) throws SQLException { - inner_results.updateNClob(columnLabel, reader, length); - } - - public void updateNString(int columnIndex, String string) throws SQLException { - inner_results.updateNString(columnIndex, string); - } - - public void updateNString(String columnLabel, String string) throws SQLException { - inner_results.updateNString(columnLabel, string); - } - - public void updateNull(int columnIndex) throws SQLException { - inner_results.updateNull(columnIndex); - } - - public void updateNull(String columnName) throws SQLException { - inner_results.updateNull(columnName); - } - - public void updateObject(int columnIndex, Object x) throws SQLException { - inner_results.updateObject(columnIndex, x); - } - - public void updateObject(String columnName, Object x) throws SQLException { - inner_results.updateObject(columnName, x); - } - - public void updateObject(int columnIndex, Object x, int scale) throws SQLException { - inner_results.updateObject(columnIndex, x, scale); - } - - public void updateObject(String columnName, Object x, int scale) throws SQLException { - inner_results.updateObject(columnName, x, scale); - } - - public void updateRef(int columnIndex, Ref x) throws SQLException { - inner_results.updateRef(columnIndex, x); - } - - public void updateRef(String columnName, Ref x) throws SQLException { - inner_results.updateRef(columnName, x); - } - - public void updateRow() throws SQLException { - inner_results.updateRow(); - } - - public void updateRowId(int columnIndex, RowId x) throws SQLException { - inner_results.updateRowId(columnIndex, x); - } - - public void updateRowId(String columnLabel, RowId x) throws SQLException { - inner_results.updateRowId(columnLabel, x); - } - - public void updateSQLXML(int columnIndex, SQLXML xmlObject) throws SQLException { - inner_results.updateSQLXML(columnIndex, xmlObject); - } - - public void updateSQLXML(String columnLabel, SQLXML xmlObject) throws SQLException { - inner_results.updateSQLXML(columnLabel, xmlObject); - } - - public void updateShort(int columnIndex, short x) throws SQLException { - inner_results.updateShort(columnIndex, x); - } - - public void updateShort(String columnName, short x) throws SQLException { - inner_results.updateShort(columnName, x); - } - - public void updateString(int columnIndex, String x) throws SQLException { - inner_results.updateString(columnIndex, x); - } - - public void updateString(String columnName, String x) throws SQLException { - inner_results.updateString(columnName, x); - } - - public void updateTime(int columnIndex, Time x) throws SQLException { - inner_results.updateTime(columnIndex, x); - } - - public void updateTime(String columnName, Time x) throws SQLException { - inner_results.updateTime(columnName, x); - } - - public void updateTimestamp(int columnIndex, Timestamp x) throws SQLException { - inner_results.updateTimestamp(columnIndex, x); - } - - public void updateTimestamp(String columnName, Timestamp x) throws SQLException { - inner_results.updateTimestamp(columnName, x); - } - - public SQLWarning getWarnings() throws SQLException { - return inner_results.getWarnings(); - } - - public void clearWarnings() throws SQLException { - inner_results.clearWarnings(); - } - - public boolean wasNull() throws SQLException { - return inner_results.wasNull(); - } - - public boolean isWrapperFor(Class iface) throws SQLException { - return inner_results.isWrapperFor(iface); - } - - public T unwrap(Class iface) throws SQLException { - return inner_results.unwrap(iface); - } - - public ForgivingHiveResultSet(ResultSet source) - { - this.inner_results = source; - } - - -} diff --git a/hive/src/main/java/org/apache/zeppelin/hive/ForgivingHiveResultSetMetadata.java b/hive/src/main/java/org/apache/zeppelin/hive/ForgivingHiveResultSetMetadata.java deleted file mode 100644 index 85e0067b0b0..00000000000 --- a/hive/src/main/java/org/apache/zeppelin/hive/ForgivingHiveResultSetMetadata.java +++ /dev/null @@ -1,111 +0,0 @@ -package org.apache.zeppelin.hive; - -import java.sql.ResultSetMetaData; -import java.sql.SQLException; -/** - * Hive does not implement all of the methods needed by CachedResultSet, - * but it could have a sensible default implementation that will work. - * @author Rusty Phillips {@literal: } - * - */ -public class ForgivingHiveResultSetMetadata implements ResultSetMetaData { - - ResultSetMetaData innerMetaData; - - public ForgivingHiveResultSetMetadata(ResultSetMetaData metaData) { - this.innerMetaData = metaData; - } - - public T unwrap(Class iface) throws SQLException { - return innerMetaData.unwrap(iface); - } - - public int getColumnCount() throws SQLException { - return innerMetaData.getColumnCount(); - } - - public boolean isAutoIncrement(int column) throws SQLException { - return innerMetaData.isAutoIncrement(column); - } - - public boolean isCaseSensitive(int column) throws SQLException { - return innerMetaData.isCaseSensitive(column); - } - - public boolean isSearchable(int column) throws SQLException { - return false; - } - - public boolean isWrapperFor(Class iface) throws SQLException { - return innerMetaData.isWrapperFor(iface); - } - - public boolean isCurrency(int column) throws SQLException { - return false; - } - - public int isNullable(int column) throws SQLException { - return innerMetaData.isNullable(column); - } - - public boolean isSigned(int column) throws SQLException { - return false; - } - - public int getColumnDisplaySize(int column) throws SQLException { - return innerMetaData.getColumnDisplaySize(column); - } - - public String getColumnLabel(int column) throws SQLException { - return innerMetaData.getColumnLabel(column); - } - - public String getColumnName(int column) throws SQLException { - return innerMetaData.getColumnName(column); - } - - public String getSchemaName(int column) throws SQLException { - return ""; - } - - public int getPrecision(int column) throws SQLException { - return innerMetaData.getPrecision(column); - } - - public int getScale(int column) throws SQLException { - return innerMetaData.getScale(column); - } - - public String getTableName(int column) throws SQLException { - return ""; - } - - public String getCatalogName(int column) throws SQLException { - return ""; - } - - public int getColumnType(int column) throws SQLException { - return innerMetaData.getColumnType(column); - } - - public String getColumnTypeName(int column) throws SQLException { - return innerMetaData.getColumnTypeName(column); - } - - public boolean isReadOnly(int column) throws SQLException { - return innerMetaData.isReadOnly(column); - } - - public boolean isWritable(int column) throws SQLException { - return innerMetaData.isWritable(column); - } - - public boolean isDefinitelyWritable(int column) throws SQLException { - return innerMetaData.isDefinitelyWritable(column); - } - - public String getColumnClassName(int column) throws SQLException { - return innerMetaData.getColumnClassName(column); - } - -} diff --git a/hive/src/main/java/org/apache/zeppelin/hive/HiveInterpreter.java b/hive/src/main/java/org/apache/zeppelin/hive/HiveInterpreter.java index f44393d29ef..1a17a766d37 100644 --- a/hive/src/main/java/org/apache/zeppelin/hive/HiveInterpreter.java +++ b/hive/src/main/java/org/apache/zeppelin/hive/HiveInterpreter.java @@ -20,7 +20,6 @@ import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; -import java.sql.ResultSetMetaData; import java.sql.SQLException; import java.sql.Statement; import java.util.List; @@ -38,9 +37,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; - /** * Hive interpreter for Zeppelin. */ From e2c93de4c453a45524ea9b81468e9af223af3c10 Mon Sep 17 00:00:00 2001 From: Rusty Phillips Date: Thu, 5 Nov 2015 15:33:43 -0500 Subject: [PATCH 3/3] Made a few cleanup changes. --- .../apache/zeppelin/notebook/NoteInterpreterLoader.java | 4 ---- .../java/org/apache/zeppelin/notebook/Paragraph.java | 9 ++------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/NoteInterpreterLoader.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/NoteInterpreterLoader.java index cda21123c5e..4e90c5a142c 100644 --- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/NoteInterpreterLoader.java +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/NoteInterpreterLoader.java @@ -18,9 +18,6 @@ package org.apache.zeppelin.notebook; import java.io.IOException; -import java.rmi.Remote; -import java.util.LinkedList; -import java.util.List; import org.apache.zeppelin.interpreter.Interpreter; import org.apache.zeppelin.interpreter.Interpreter.RegisteredInterpreter; @@ -28,7 +25,6 @@ import org.apache.zeppelin.interpreter.InterpreterFactory; import org.apache.zeppelin.interpreter.InterpreterGroup; import org.apache.zeppelin.interpreter.InterpreterSetting; -import org.apache.zeppelin.interpreter.RemoteResultRepo; import org.apache.zeppelin.interpreter.ResultRepoFactory; /** diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Paragraph.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Paragraph.java index 30fbe604095..698654ec265 100644 --- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Paragraph.java +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Paragraph.java @@ -203,13 +203,8 @@ protected Object jobRun() throws Throwable { settings.clear(); } else if (repl.getFormType() == FormType.SIMPLE) { String scriptBody = getScriptBody(); - Map inputs = Input.extractSimpleQueryParam(scriptBody); // inputs - // will - // be - // built - // from - // script - // body + Map inputs = Input.extractSimpleQueryParam(scriptBody); // inputs will be built + // from script body settings.setForms(inputs); script = Input.getSimpleQuery(settings.getParams(), scriptBody); }