Skip to content

Commit

Permalink
Move jsonDataType() definition to DataType
Browse files Browse the repository at this point in the history
  • Loading branch information
findepi committed Mar 13, 2019
1 parent 3792816 commit ac96917
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import java.time.ZoneId;
import java.util.function.Function;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkState;
import static com.google.common.base.Verify.verify;
import static com.google.common.io.BaseEncoding.base16;
Expand All @@ -48,11 +47,11 @@
import static io.prestosql.tests.datatype.DataType.decimalDataType;
import static io.prestosql.tests.datatype.DataType.doubleDataType;
import static io.prestosql.tests.datatype.DataType.integerDataType;
import static io.prestosql.tests.datatype.DataType.jsonDataType;
import static io.prestosql.tests.datatype.DataType.realDataType;
import static io.prestosql.tests.datatype.DataType.smallintDataType;
import static io.prestosql.tests.datatype.DataType.varbinaryDataType;
import static io.prestosql.tests.datatype.DataType.varcharDataType;
import static io.prestosql.type.JsonType.JSON;
import static java.lang.String.format;
import static java.nio.charset.StandardCharsets.UTF_16LE;
import static java.nio.charset.StandardCharsets.UTF_8;
Expand Down Expand Up @@ -352,18 +351,6 @@ private static DataType<byte[]> byteaDataType()
identity());
}

private static DataType<String> jsonDataType()
{
return dataType(
"json",
JSON,
value -> {
checkArgument(!value.contains("'"));
return format("JSON '%s'", value);
},
identity());
}

private DataSetup prestoCreateAsSelect(String tableNamePrefix)
{
return new CreateAsSelectDataSetup(new PrestoSqlExecutor(getQueryRunner()), tableNamePrefix);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@
import java.util.Optional;
import java.util.function.Function;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Strings.padEnd;
import static com.google.common.io.BaseEncoding.base16;
import static io.prestosql.spi.type.CharType.createCharType;
import static io.prestosql.spi.type.DateType.DATE;
import static io.prestosql.spi.type.DecimalType.createDecimalType;
import static io.prestosql.spi.type.VarcharType.createUnboundedVarcharType;
import static io.prestosql.type.JsonType.JSON;
import static java.lang.String.format;
import static java.math.RoundingMode.UNNECESSARY;
import static java.util.function.Function.identity;
Expand Down Expand Up @@ -150,6 +152,18 @@ public static DataType<LocalDate> dateDataType()
identity());
}

public static DataType<String> jsonDataType()
{
return dataType(
"json",
JSON,
value -> {
checkArgument(!value.contains("'"));
return format("JSON '%s'", value);
},
identity());
}

private static String quote(String value)
{
return "'" + value + "'";
Expand Down

0 comments on commit ac96917

Please sign in to comment.