-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SNOW-956803 - Mapping of structured type fields description
- Loading branch information
1 parent
df8c4ec
commit ff12158
Showing
7 changed files
with
530 additions
and
80 deletions.
There are no files selected for viewing
167 changes: 167 additions & 0 deletions
167
src/main/java/net/snowflake/client/core/JsonSQLOutput.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
package net.snowflake.client.core; | ||
|
||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
|
||
import java.io.InputStream; | ||
import java.io.Reader; | ||
import java.math.BigDecimal; | ||
import java.net.URL; | ||
import java.sql.*; | ||
import java.sql.Date; | ||
import java.util.*; | ||
|
||
public class JsonSQLOutput implements SQLOutput { | ||
|
||
private Vector attribs = new Vector(); | ||
private Map map = new HashMap(); | ||
private final ObjectMapper OBJECT_MAPPER = ObjectMapperFactory.getObjectMapper(); | ||
|
||
public String getJsonString() { | ||
try { | ||
return OBJECT_MAPPER.writeValueAsString(attribs); | ||
} catch (JsonProcessingException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
@Override | ||
public void writeString(String value) throws SQLException { | ||
attribs.add(value); | ||
} | ||
|
||
@Override | ||
public void writeBoolean(boolean x) throws SQLException { | ||
|
||
} | ||
|
||
@Override | ||
public void writeByte(byte x) throws SQLException { | ||
|
||
} | ||
|
||
@Override | ||
public void writeShort(short x) throws SQLException { | ||
|
||
} | ||
|
||
@Override | ||
public void writeInt(int x) throws SQLException { | ||
|
||
} | ||
|
||
@Override | ||
public void writeLong(long x) throws SQLException { | ||
|
||
} | ||
|
||
@Override | ||
public void writeFloat(float x) throws SQLException { | ||
|
||
} | ||
|
||
@Override | ||
public void writeDouble(double x) throws SQLException { | ||
|
||
} | ||
|
||
@Override | ||
public void writeBigDecimal(BigDecimal x) throws SQLException { | ||
|
||
} | ||
|
||
@Override | ||
public void writeBytes(byte[] x) throws SQLException { | ||
|
||
} | ||
|
||
@Override | ||
public void writeDate(Date x) throws SQLException { | ||
|
||
} | ||
|
||
@Override | ||
public void writeTime(Time x) throws SQLException { | ||
|
||
} | ||
|
||
@Override | ||
public void writeTimestamp(Timestamp x) throws SQLException { | ||
|
||
} | ||
|
||
@Override | ||
public void writeCharacterStream(Reader x) throws SQLException { | ||
|
||
} | ||
|
||
@Override | ||
public void writeAsciiStream(InputStream x) throws SQLException { | ||
|
||
} | ||
|
||
@Override | ||
public void writeBinaryStream(InputStream x) throws SQLException { | ||
|
||
} | ||
|
||
@Override | ||
public void writeObject(SQLData x) throws SQLException { | ||
try { | ||
attribs.add(OBJECT_MAPPER.writeValueAsString(x)); | ||
} catch (JsonProcessingException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
@Override | ||
public void writeRef(Ref x) throws SQLException { | ||
|
||
} | ||
|
||
@Override | ||
public void writeBlob(Blob x) throws SQLException { | ||
|
||
} | ||
|
||
@Override | ||
public void writeClob(Clob x) throws SQLException { | ||
|
||
} | ||
|
||
@Override | ||
public void writeStruct(Struct x) throws SQLException { | ||
|
||
} | ||
|
||
@Override | ||
public void writeArray(Array x) throws SQLException { | ||
|
||
} | ||
|
||
@Override | ||
public void writeURL(URL x) throws SQLException { | ||
|
||
} | ||
|
||
@Override | ||
public void writeNString(String x) throws SQLException { | ||
|
||
} | ||
|
||
@Override | ||
public void writeNClob(NClob x) throws SQLException { | ||
|
||
} | ||
|
||
@Override | ||
public void writeRowId(RowId x) throws SQLException { | ||
|
||
} | ||
|
||
@Override | ||
public void writeSQLXML(SQLXML x) throws SQLException { | ||
|
||
} | ||
} | ||
|
25 changes: 25 additions & 0 deletions
25
src/main/java/net/snowflake/client/jdbc/ColumnTypeInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package net.snowflake.client.jdbc; | ||
|
||
public class ColumnTypeInfo { | ||
private int columnType; | ||
private String extColTypeName; | ||
private SnowflakeType snowflakeType; | ||
|
||
public ColumnTypeInfo(int columnType, String extColTypeName, SnowflakeType snowflakeType) { | ||
this.columnType = columnType; | ||
this.extColTypeName = extColTypeName; | ||
this.snowflakeType = snowflakeType; | ||
} | ||
|
||
public int getColumnType() { | ||
return columnType; | ||
} | ||
|
||
public String getExtColTypeName() { | ||
return extColTypeName; | ||
} | ||
|
||
public SnowflakeType getSnowflakeType() { | ||
return snowflakeType; | ||
} | ||
} |
115 changes: 115 additions & 0 deletions
115
src/main/java/net/snowflake/client/jdbc/MetadataField.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
package net.snowflake.client.jdbc; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
public class MetadataField { | ||
|
||
public MetadataField() { | ||
} | ||
|
||
private String name; | ||
private String typeName; | ||
private int type; | ||
private boolean nullable; | ||
@JsonProperty("byteLength") | ||
private int length; | ||
private int precision; | ||
private int scale; | ||
private boolean fixed; | ||
private SnowflakeType base; | ||
private MetadataField[] fields; | ||
|
||
public MetadataField(String name, String typeName, int type, boolean nullable, int length, int precision, | ||
int scale, boolean fixed, SnowflakeType base, MetadataField[] fields) { | ||
this.name = name; | ||
this.typeName = typeName; | ||
this.type = type; | ||
this.nullable = nullable; | ||
this.length = length; | ||
this.precision = precision; | ||
this.scale = scale; | ||
this.fixed = fixed; | ||
this.base = base; | ||
this.fields = fields; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getTypeName() { | ||
return typeName; | ||
} | ||
|
||
public void setTypeName(String typeName) { | ||
this.typeName = typeName; | ||
} | ||
|
||
public int getType() { | ||
return type; | ||
} | ||
|
||
public void setType(int type) { | ||
this.type = type; | ||
} | ||
|
||
public boolean isNullable() { | ||
return nullable; | ||
} | ||
|
||
public void setNullable(boolean nullable) { | ||
this.nullable = nullable; | ||
} | ||
|
||
public int getLength() { | ||
return length; | ||
} | ||
|
||
public void setLength(int length) { | ||
this.length = length; | ||
} | ||
|
||
public int getPrecision() { | ||
return precision; | ||
} | ||
|
||
public void setPrecision(int precision) { | ||
this.precision = precision; | ||
} | ||
|
||
public int getScale() { | ||
return scale; | ||
} | ||
|
||
public void setScale(int scale) { | ||
this.scale = scale; | ||
} | ||
|
||
public boolean isFixed() { | ||
return fixed; | ||
} | ||
|
||
public void setFixed(boolean fixed) { | ||
this.fixed = fixed; | ||
} | ||
|
||
public SnowflakeType getBase() { | ||
return base; | ||
} | ||
|
||
public void setBase(SnowflakeType base) { | ||
this.base = base; | ||
} | ||
|
||
public MetadataField[] getFields() { | ||
return fields; | ||
} | ||
|
||
public void setFields(MetadataField[] fields) { | ||
this.fields = fields; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.