package org.apache.seatunnel.transform.conversion;

import com.google.auto.service.AutoService;
import org.apache.seatunnel.api.configuration.util.OptionRule;
import org.apache.seatunnel.api.table.catalog.CatalogTable;
import org.apache.seatunnel.api.table.connector.TableTransform;
import org.apache.seatunnel.api.table.factory.Factory;
import org.apache.seatunnel.api.table.factory.TableFactoryContext;
import org.apache.seatunnel.api.table.factory.TableTransformFactory;

@AutoService(Factory.class)
public class TypeConversionTransformFactory implements TableTransformFactory {
    @Override
    public String factoryIdentifier() {
        return "TypeConversion";
    }

    @Override
    public OptionRule optionRule() {
        return OptionRule.builder()
                .required(TypeConversionTransformConfig.KEY_FILTER_FIELD).build();
    }

    @Override
    public TableTransform createTransform(TableFactoryContext context) {
        CatalogTable catalogTable = context.getCatalogTable();
        return() -> new TypeConversionTransform(context.getOptions(), catalogTable);
    }
}
