valueBuilder.setType(Common.Rep.STRING).setStringValue((String) obj); break; case GET_DEFAULT_TRANSACTION_ISOLATION:
case BYTE_STRING: case STRING: builder.setStringValue((String) value); break; case PRIMITIVE_CHAR: case CHARACTER: builder.setStringValue(Character.toString((char) value)); break; case BYTE:
valueBuilder.setType(Common.Rep.STRING).setStringValue((String) obj); break; case GET_DEFAULT_TRANSACTION_ISOLATION: value = obj.toString(); valueBuilder.setType(Common.Rep.STRING).setStringValue(value);
builder.setStringValue((String) o); builder.setStringValue(Base64.encodeBytes((byte[]) o)); case PRIMITIVE_CHAR: case CHARACTER: builder.setStringValue(Character.toString((char) o)); return; case BYTE: case BIG_DECIMAL: final BigDecimal bigDecimal = (BigDecimal) o; builder.setStringValue(bigDecimal.toString()); return; case NUMBER:
builder.setStringValue((String) o); builder.setStringValue(Base64.encodeBytes((byte[]) o)); case PRIMITIVE_CHAR: case CHARACTER: builder.setStringValue(Character.toString((char) o)); return; case BYTE: case BIG_DECIMAL: final BigDecimal bigDecimal = (BigDecimal) o; builder.setStringValue(bigDecimal.toString()); return; case NUMBER:
.build()); values.add(Common.TypedValue.newBuilder().setType(Common.Rep.STRING) .setStringValue("my_string").build());
.build()); values.add(Common.TypedValue.newBuilder().setType(Common.Rep.STRING) .setStringValue("my_string").build());
valueBuilder.setType(Common.Rep.STRING).setStringValue((String) obj); break; case GET_DEFAULT_TRANSACTION_ISOLATION: value = obj.toString(); valueBuilder.setType(Common.Rep.STRING).setStringValue(value);
.build()); values.add(Common.TypedValue.newBuilder().setType(Common.Rep.STRING) .setStringValue("my_string").build());
.setStringValue((String) element); } else if (element instanceof Character) { valueBuilder.setType(Common.Rep.CHARACTER) .setStringValue(((Character) element).toString());
@Test public void testLegacyBase64StringEncodingForBytes() { // CALCITE-1103 CALCITE-1209 We observed that binary data was being // serialized as base-64 encoded strings instead of the native binary // data type in protobufs. We need to still handle older clients sending // data in this form. final byte[] bytes = "asdf".getBytes(UTF_8); final String base64Str = Base64.encodeBytes(bytes); Common.TypedValue.Builder builder = Common.TypedValue.newBuilder(); builder.setStringValue(base64Str); builder.setType(Common.Rep.BYTE_STRING); Common.TypedValue protoTv = builder.build(); TypedValue tv = TypedValue.fromProto(protoTv); assertEquals(Rep.BYTE_STRING, tv.type); assertEquals(base64Str, tv.value); }
@Test public void testLegacyBase64StringEncodingForBytes() { // CALCITE-1103 CALCITE-1209 We observed that binary data was being // serialized as base-64 encoded strings instead of the native binary // data type in protobufs. We need to still handle older clients sending // data in this form. final byte[] bytes = "asdf".getBytes(UTF_8); final String base64Str = Base64.encodeBytes(bytes); Common.TypedValue.Builder builder = Common.TypedValue.newBuilder(); builder.setStringValue(base64Str); builder.setType(Common.Rep.BYTE_STRING); Common.TypedValue protoTv = builder.build(); TypedValue tv = TypedValue.fromProto(protoTv); assertEquals(Rep.BYTE_STRING, tv.type); assertEquals(base64Str, tv.value); }