com.facebook.presto.jdbc.internal.client.FixJsonDataUtils Maven / Gradle / Ivy
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.facebook.presto.jdbc.internal.client;
import com.facebook.presto.jdbc.internal.common.type.NamedTypeSignature;
import com.facebook.presto.jdbc.internal.common.type.ParameterKind;
import com.facebook.presto.jdbc.internal.common.type.TypeSignature;
import com.facebook.presto.jdbc.internal.common.type.TypeSignatureParameter;
import com.facebook.presto.jdbc.internal.guava.collect.ImmutableList;
import java.util.ArrayList;
import java.util.Base64;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import static com.facebook.presto.jdbc.internal.common.type.StandardTypes.ARRAY;
import static com.facebook.presto.jdbc.internal.common.type.StandardTypes.BIGINT;
import static com.facebook.presto.jdbc.internal.common.type.StandardTypes.BING_TILE;
import static com.facebook.presto.jdbc.internal.common.type.StandardTypes.BOOLEAN;
import static com.facebook.presto.jdbc.internal.common.type.StandardTypes.CHAR;
import static com.facebook.presto.jdbc.internal.common.type.StandardTypes.DATE;
import static com.facebook.presto.jdbc.internal.common.type.StandardTypes.DECIMAL;
import static com.facebook.presto.jdbc.internal.common.type.StandardTypes.DOUBLE;
import static com.facebook.presto.jdbc.internal.common.type.StandardTypes.GEOMETRY;
import static com.facebook.presto.jdbc.internal.common.type.StandardTypes.INTEGER;
import static com.facebook.presto.jdbc.internal.common.type.StandardTypes.INTERVAL_DAY_TO_SECOND;
import static com.facebook.presto.jdbc.internal.common.type.StandardTypes.INTERVAL_YEAR_TO_MONTH;
import static com.facebook.presto.jdbc.internal.common.type.StandardTypes.IPADDRESS;
import static com.facebook.presto.jdbc.internal.common.type.StandardTypes.IPPREFIX;
import static com.facebook.presto.jdbc.internal.common.type.StandardTypes.JSON;
import static com.facebook.presto.jdbc.internal.common.type.StandardTypes.MAP;
import static com.facebook.presto.jdbc.internal.common.type.StandardTypes.REAL;
import static com.facebook.presto.jdbc.internal.common.type.StandardTypes.ROW;
import static com.facebook.presto.jdbc.internal.common.type.StandardTypes.SMALLINT;
import static com.facebook.presto.jdbc.internal.common.type.StandardTypes.TIME;
import static com.facebook.presto.jdbc.internal.common.type.StandardTypes.TIMESTAMP;
import static com.facebook.presto.jdbc.internal.common.type.StandardTypes.TIMESTAMP_WITH_TIME_ZONE;
import static com.facebook.presto.jdbc.internal.common.type.StandardTypes.TIME_WITH_TIME_ZONE;
import static com.facebook.presto.jdbc.internal.common.type.StandardTypes.TINYINT;
import static com.facebook.presto.jdbc.internal.common.type.StandardTypes.VARCHAR;
import static com.facebook.presto.jdbc.internal.common.type.TypeSignature.parseTypeSignature;
import static com.facebook.presto.jdbc.internal.guava.base.Preconditions.checkArgument;
import static java.util.Collections.unmodifiableList;
import static java.util.Objects.requireNonNull;
import static java.util.stream.Collectors.toList;
final class FixJsonDataUtils
{
private FixJsonDataUtils() {}
public static Iterable> fixData(List columns, Iterable> data)
{
if (data == null) {
return null;
}
requireNonNull(columns, "columns is null");
List signatures = columns.stream()
.map(column -> parseTypeSignature(column.getType()))
.collect(toList());
ImmutableList.Builder> rows = ImmutableList.builder();
for (List
© 2015 - 2024 Weber Informatics LLC | Privacy Policy