All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.alibaba.ververica.connectors.odps.OdpsDynamicTableSinkFactory Maven / Gradle / Ivy

There is a newer version: 1.17-vvr-8.0.8
Show newest version
/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you 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.alibaba.ververica.connectors.odps;

import org.apache.flink.configuration.ConfigOption;
import org.apache.flink.configuration.ReadableConfig;
import org.apache.flink.table.api.TableSchema;
import org.apache.flink.table.connector.sink.DynamicTableSink;
import org.apache.flink.table.factories.DynamicTableSinkFactory;
import org.apache.flink.table.factories.FactoryUtil;
import org.apache.flink.table.types.DataType;

import com.alibaba.ververica.connectors.odps.sink.OdpsDynamicTableSink;

import java.util.HashSet;
import java.util.Set;

import static com.alibaba.ververica.connectors.common.util.ContextUtil.transformContext;
import static com.alibaba.ververica.connectors.odps.OdpsOptions.ACCESS_ID;
import static com.alibaba.ververica.connectors.odps.OdpsOptions.ACCESS_KEY;
import static com.alibaba.ververica.connectors.odps.OdpsOptions.DYNAMIC_PART_LIMIT;
import static com.alibaba.ververica.connectors.odps.OdpsOptions.END_POINT;
import static com.alibaba.ververica.connectors.odps.OdpsOptions.FLUSH_INTERVAL_MS_CONF;
import static com.alibaba.ververica.connectors.odps.OdpsOptions.PARTITION;
import static com.alibaba.ververica.connectors.odps.OdpsOptions.PROJECT_NAME;
import static com.alibaba.ververica.connectors.odps.OdpsOptions.TABLE_NAME;
import static com.alibaba.ververica.connectors.odps.OdpsOptions.TUNNEL_END_POINT;

/**
 * Factory for OdpsDynamicTableSink.
 */
public class OdpsDynamicTableSinkFactory implements DynamicTableSinkFactory {

	public static final String IDENTIFIER = "odps";

	@Override
	public DynamicTableSink createDynamicTableSink(Context context) {
		transformContext(this, context);
		final FactoryUtil.TableFactoryHelper helper = FactoryUtil.createTableFactoryHelper(this, context);
		final ReadableConfig config = helper.getOptions();
		helper.validate();
		TableSchema tableSchema = context.getCatalogTable().getSchema();
		DataType rowType = tableSchema.toPhysicalRowDataType();

		return new OdpsDynamicTableSink(tableSchema, rowType, config);
	}

	@Override
	public String factoryIdentifier() {
		return IDENTIFIER;
	}

	@Override
	public Set> requiredOptions() {
		Set> requiredOptions = new HashSet<>();
		requiredOptions.add(END_POINT);
		requiredOptions.add(PROJECT_NAME);
		requiredOptions.add(TABLE_NAME);
		requiredOptions.add(ACCESS_ID);
		requiredOptions.add(ACCESS_KEY);
		return requiredOptions;
	}

	@Override
	public Set> optionalOptions() {
		Set> optionals = new HashSet<>();
		optionals.add(PARTITION);
		optionals.add(TUNNEL_END_POINT);
		optionals.add(FLUSH_INTERVAL_MS_CONF);
		optionals.add(DYNAMIC_PART_LIMIT);
		return optionals;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy