Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor cleanup in Faker connector #23908

Merged
merged 10 commits into from
Oct 25, 2024
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -15,60 +15,31 @@

import io.trino.spi.connector.ColumnHandle;
import io.trino.spi.connector.ColumnMetadata;
import io.trino.spi.type.Type;

import java.util.Map;
import java.util.Optional;

import static java.util.Objects.requireNonNull;

public class ColumnInfo
public record ColumnInfo(ColumnHandle handle, ColumnMetadata metadata)
{
public static final String NULL_PROBABILITY_PROPERTY = "null_probability";
public static final String GENERATOR_PROPERTY = "generator";

private final ColumnHandle handle;
private final String name;
private final Type type;
private ColumnMetadata metadata;

public ColumnInfo(ColumnHandle handle, String name, Type type, Map<String, Object> properties, Optional<String> comment)
{
this(handle, ColumnMetadata.builder()
.setName(name)
.setType(type)
.setProperties(properties)
.setComment(comment)
.build());
}

public ColumnInfo(ColumnHandle handle, ColumnMetadata metadata)
{
this.handle = requireNonNull(handle, "handle is null");
this.metadata = requireNonNull(metadata, "metadata is null");
this.name = metadata.getName();
this.type = metadata.getType();
}

public ColumnHandle getHandle()
{
return handle;
}

public String getName()
public ColumnInfo
{
return name;
requireNonNull(handle, "handle is null");
requireNonNull(metadata, "metadata is null");
}

public ColumnMetadata getMetadata()
public String name()
{
return metadata;
return metadata.getName();
}

@Override
public String toString()
{
return name + "::" + type;
return metadata.getName() + "::" + metadata.getType();
}

public ColumnInfo withComment(Optional<String> comment)
Expand Down

This file was deleted.

Loading