com.hazelcast.jet.sql.impl.connector.file.FileTableFunction Maven / Gradle / Ivy
/*
* Copyright 2021 Hazelcast Inc.
*
* Licensed under the Hazelcast Community License (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://hazelcast.com/hazelcast-community-license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.hazelcast.jet.sql.impl.connector.file;
import com.hazelcast.internal.util.UuidUtil;
import com.hazelcast.jet.sql.impl.schema.JetDynamicTableFunction;
import com.hazelcast.jet.sql.impl.schema.JetTableFunctionParameter;
import com.hazelcast.sql.impl.schema.MappingField;
import com.hazelcast.jet.sql.impl.validate.operators.typeinference.HazelcastOperandTypeInference;
import com.hazelcast.jet.sql.impl.validate.operand.TypedOperandChecker;
import com.hazelcast.jet.sql.impl.validate.operators.typeinference.ReplaceUnknownOperandTypeInference;
import com.hazelcast.sql.impl.schema.Table;
import com.hazelcast.org.apache.calcite.sql.SqlOperandCountRange;
import com.hazelcast.org.apache.calcite.sql.type.SqlOperandCountRanges;
import com.hazelcast.org.apache.calcite.sql.type.SqlTypeName;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.hazelcast.jet.sql.impl.connector.SqlConnector.OPTION_FORMAT;
import static com.hazelcast.jet.sql.impl.connector.file.FileSqlConnector.OPTION_GLOB;
import static com.hazelcast.jet.sql.impl.connector.file.FileSqlConnector.OPTION_OPTIONS;
import static com.hazelcast.jet.sql.impl.connector.file.FileSqlConnector.OPTION_PATH;
import static com.hazelcast.jet.sql.impl.connector.file.FileSqlConnector.OPTION_SHARED_FILE_SYSTEM;
import static java.util.Arrays.asList;
import static java.util.Collections.emptyList;
import static com.hazelcast.org.apache.calcite.sql.type.SqlTypeName.ANY;
public final class FileTableFunction extends JetDynamicTableFunction {
private static final String SCHEMA_NAME_FILES = "files";
private static final List PARAMETERS = asList(
new JetTableFunctionParameter(0, OPTION_PATH, SqlTypeName.VARCHAR, TypedOperandChecker.VARCHAR),
new JetTableFunctionParameter(1, OPTION_GLOB, SqlTypeName.VARCHAR, TypedOperandChecker.VARCHAR),
new JetTableFunctionParameter(2, OPTION_SHARED_FILE_SYSTEM, SqlTypeName.VARCHAR, TypedOperandChecker.VARCHAR),
new JetTableFunctionParameter(3, OPTION_OPTIONS, SqlTypeName.MAP, TypedOperandChecker.MAP)
);
public FileTableFunction(String name, String format) {
super(
name,
PARAMETERS,
arguments -> toTable(arguments, format),
new HazelcastOperandTypeInference(PARAMETERS, new ReplaceUnknownOperandTypeInference(ANY)),
FileSqlConnector.INSTANCE
);
}
@Override
public SqlOperandCountRange getOperandCountRange() {
return SqlOperandCountRanges.between(1, PARAMETERS.size());
}
private static Table toTable(List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy