Closed
Show file tree
Hide file tree
Changes from 1 commit
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Failed to load files.
PrevPrevious commit
Next Next commit
Use String for JSON directly (does not pass ValueBinderTest)
  • Loading branch information
@zoercai
zoercai committedApr 12, 2021
commit b8e4f5779083a6883cfa0d0663007fd9bb750668
Original file line numberDiff line numberDiff line change
Expand Up@@ -379,7 +379,7 @@ private Object writeReplace() {
builder.set(fieldName).to((String) value);
break;
case JSON:
builder.set(fieldName).to((Json) value);
builder.set(fieldName).to((String) value);
break;
case BYTES:
builder.set(fieldName).to((ByteArray) value);
Expand DownExpand Up@@ -408,7 +408,7 @@ private Object writeReplace() {
builder.set(fieldName).toStringArray((Iterable<String>) value);
break;
case JSON:
builder.set(fieldName).toJsonArray((Iterable<Json>) value);
builder.set(fieldName).toJsonArray((Iterable<String>) value);
break;
case BYTES:
builder.set(fieldName).toBytesArray((Iterable<ByteArray>) value);
Expand DownExpand Up@@ -486,11 +486,9 @@ private static Object decodeValue(Type fieldType, com.google.protobuf.Value prot
case NUMERIC:
return new BigDecimal(proto.getStringValue());
case STRING:
checkType(fieldType, proto, KindCase.STRING_VALUE);
return proto.getStringValue();
case JSON:
checkType(fieldType, proto, KindCase.STRING_VALUE);
return new Json(proto.getStringValue());
return proto.getStringValue();
case BYTES:
checkType(fieldType, proto, KindCase.STRING_VALUE);
return ByteArray.fromBase64(proto.getStringValue());
Expand DownExpand Up@@ -572,7 +570,7 @@ public String apply(com.google.protobuf.Value input) {
list.add(
value.getKindCase() == KindCase.NULL_VALUE
? null
: new Json(value.getStringValue()));
: value.getStringValue());
}
return list;
}
Expand DownExpand Up@@ -685,8 +683,8 @@ protected String getStringInternal(int columnIndex) {
}

@Override
protected Json getJsonInternal(int columnIndex) {
return (Json) rowData.get(columnIndex);
protected String getJsonInternal(int columnIndex) {
return (String) rowData.get(columnIndex);
}

@Override
Expand DownExpand Up@@ -763,8 +761,8 @@ protected List<String> getStringListInternal(int columnIndex) {

@Override
@SuppressWarnings("unchecked") // We know ARRAY<JSON> produces a List<JSON>.
protected List<Json> getJsonListInternal(int columnIndex) {
return Collections.unmodifiableList((List<Json>) rowData.get(columnIndex));
protected List<String> getJsonListInternal(int columnIndex) {
return Collections.unmodifiableList((List<String>) rowData.get(columnIndex));
}

@Override
Expand DownExpand Up@@ -1142,8 +1140,8 @@ static double valueProtoToFloat64(com.google.protobuf.Value proto) {
+ " \"Infinity\", \"-Infinity\", or \"NaN\" but was "
+ proto.getKindCase()
+ (proto.getKindCase() == KindCase.STRING_VALUE
? " with value \"" + proto.getStringValue() + "\""
: ""));
? " with value \"" + proto.getStringValue() + "\""
: ""));
}
return proto.getNumberValue();
}
Expand DownExpand Up@@ -1297,7 +1295,7 @@ protected String getStringInternal(int columnIndex) {
}

@Override
protected Json getJsonInternal(int columnIndex) {
protected String getJsonInternal(int columnIndex) {
return currRow().getJsonInternal(columnIndex);
}

Expand DownExpand Up@@ -1357,7 +1355,7 @@ protected List<String> getStringListInternal(int columnIndex) {
}

@Override
protected List<Json> getJsonListInternal(int columnIndex) {
protected List<String> getJsonListInternal(int columnIndex) {
return currRow().getJsonListInternal(columnIndex);
}

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -43,7 +43,7 @@ public abstract class AbstractStructReader implements StructReader {

protected abstract String getStringInternal(int columnIndex);

protected abstract Json getJsonInternal(int columnIndex);
protected abstract String getJsonInternal(int columnIndex);

protected abstract ByteArray getBytesInternal(int columnIndex);

Expand All@@ -67,7 +67,7 @@ public abstract class AbstractStructReader implements StructReader {

protected abstract List<String> getStringListInternal(int columnIndex);

protected abstract List<Json> getJsonListInternal(int columnIndex);
protected abstract List<String> getJsonListInternal(int columnIndex);

protected abstract List<ByteArray> getBytesListInternal(int columnIndex);

Expand DownExpand Up@@ -163,13 +163,13 @@ public String getString(String columnName) {
}

@Override
public Json getJson(int columnIndex) {
public String getJson(int columnIndex) {
checkNonNullOfType(columnIndex, Type.json(), columnIndex);
return getJsonInternal(columnIndex);
}

@Override
public Json getJson(String columnName) {
public String getJson(String columnName) {
int columnIndex = getColumnIndex(columnName);
checkNonNullOfType(columnIndex, Type.json(), columnName);
return getJsonInternal(columnIndex);
Expand DownExpand Up@@ -319,13 +319,13 @@ public List<String> getStringList(String columnName) {
}

@Override
public List<Json> getJsonList(int columnIndex) {
public List<String> getJsonList(int columnIndex) {
checkNonNullOfType(columnIndex, Type.array(Type.json()), columnIndex);
return getJsonListInternal(columnIndex);
}

@Override
public List<Json> getJsonList(String columnName) {
public List<String> getJsonList(String columnName) {
int columnIndex = getColumnIndex(columnName);
checkNonNullOfType(columnIndex, Type.array(Type.json()), columnName);
return getJsonListInternal(columnIndex);
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -157,13 +157,13 @@ public String getString(String columnName) {
}

@Override
public Json getJson(int columnIndex) {
public String getJson(int columnIndex) {
checkValidState();
return delegate.get().getJson(columnIndex);
}

@Override
public Json getJson(String columnName) {
public String getJson(String columnName) {
checkValidState();
return delegate.get().getJson(columnName);
}
Expand DownExpand Up@@ -299,13 +299,13 @@ public List<String> getStringList(String columnName) {
}

@Override
public List<Json> getJsonList(int columnIndex) {
public List<String> getJsonList(int columnIndex) {
checkValidState();
return delegate.get().getJsonList(columnIndex);
}

@Override
public List<Json> getJsonList(String columnName) {
public List<String> getJsonList(String columnName) {
checkValidState();
return delegate.get().getJsonList(columnName);
}
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -193,7 +193,7 @@ protected String getStringInternal(int columnIndex) {
}

@Override
protected Json getJsonInternal(int columnIndex) {
protected String getJsonInternal(int columnIndex) {
return values.get(columnIndex).getJson();
}

Expand DownExpand Up@@ -258,7 +258,7 @@ protected List<String> getStringListInternal(int columnIndex) {
}

@Override
protected List<Json> getJsonListInternal(int columnIndex) {
protected List<String> getJsonListInternal(int columnIndex) {
return values.get(columnIndex).getJsonArray();
}

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -114,11 +114,11 @@ public interface StructReader {
/** Returns the value of a non-{@code NULL} column with type {@link Type#string()}. */
String getString(String columnName);

/** Returns the value of a non-{@code NULL} column with type {@link Type#json()}. */
Json getJson(int columnIndex);
/** Returns the value of a non-{@code NULL} column with type {@link Type#string()}. */
String getJson(int columnIndex);

/** Returns the value of a non-{@code NULL} column with type {@link Type#json()}. */
Json getJson(String columnName);
/** Returns the value of a non-{@code NULL} column with type {@link Type#string()}. */
String getJson(String columnName);

/** Returns the value of a non-{@code NULL} column with type {@link Type#bytes()}. */
ByteArray getBytes(int columnIndex);
Expand DownExpand Up@@ -224,11 +224,11 @@ public interface StructReader {
/** Returns the value of a non-{@code NULL} column with type {@code Type.array(Type.string())}. */
List<String> getStringList(String columnName);

/** Returns the value of a non-{@code NULL} column with type {@code Type.array(Type.json())}. */
List<Json> getJsonList(int columnIndex);
/** Returns the value of a non-{@code NULL} column with type {@code Type.array(Type.string())}. */
List<String> getJsonList(int columnIndex);

/** Returns the value of a non-{@code NULL} column with type {@code Type.array(Type.json())}. */
List<Json> getJsonList(String columnName);
/** Returns the value of a non-{@code NULL} column with type {@code Type.array(Type.string())}. */
List<String> getJsonList(String columnName);

/** Returns the value of a non-{@code NULL} column with type {@code Type.array(Type.bytes())}. */
List<ByteArray> getBytesList(int columnIndex);
Expand Down
Loading