-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fefa142
commit aa18f32
Showing
29 changed files
with
3,052 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,171 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>io.trino</groupId> | ||
<artifactId>trino-root</artifactId> | ||
<version>461-SNAPSHOT</version> | ||
<relativePath>../../pom.xml</relativePath> | ||
</parent> | ||
|
||
<artifactId>trino-faker</artifactId> | ||
<packaging>trino-plugin</packaging> | ||
<description>Trino - Faker connector</description> | ||
|
||
<dependencies> | ||
|
||
<dependency> | ||
<groupId>com.google.errorprone</groupId> | ||
<artifactId>error_prone_annotations</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.google.guava</groupId> | ||
<artifactId>guava</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.google.inject</groupId> | ||
<artifactId>guice</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.airlift</groupId> | ||
<artifactId>bootstrap</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.airlift</groupId> | ||
<artifactId>configuration</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.trino</groupId> | ||
<artifactId>trino-main</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.trino</groupId> | ||
<artifactId>trino-plugin-toolkit</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>jakarta.inject</groupId> | ||
<artifactId>jakarta.inject-api</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>jakarta.validation</groupId> | ||
<artifactId>jakarta.validation-api</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>net.datafaker</groupId> | ||
<artifactId>datafaker</artifactId> | ||
<version>2.3.1</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
<artifactId>jackson-annotations</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.airlift</groupId> | ||
<artifactId>slice</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.opentelemetry</groupId> | ||
<artifactId>opentelemetry-api</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.opentelemetry</groupId> | ||
<artifactId>opentelemetry-context</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.trino</groupId> | ||
<artifactId>trino-spi</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.openjdk.jol</groupId> | ||
<artifactId>jol-core</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.airlift</groupId> | ||
<artifactId>units</artifactId> | ||
<scope>runtime</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.airlift</groupId> | ||
<artifactId>junit-extensions</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.airlift</groupId> | ||
<artifactId>testing</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.trino</groupId> | ||
<artifactId>trino-memory</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.trino</groupId> | ||
<artifactId>trino-testing</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.trino</groupId> | ||
<artifactId>trino-tpch</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.assertj</groupId> | ||
<artifactId>assertj-core</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.codehaus.plexus</groupId> | ||
<artifactId>plexus-utils</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-api</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.airlift</groupId> | ||
<artifactId>log</artifactId> | ||
<scope>test-jar</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.airlift</groupId> | ||
<artifactId>log-manager</artifactId> | ||
<scope>test-jar</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
80 changes: 80 additions & 0 deletions
80
plugin/trino-faker/src/main/java/io/trino/plugin/faker/ColumnInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
* 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 io.trino.plugin.faker; | ||
|
||
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 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() | ||
{ | ||
return name; | ||
} | ||
|
||
public ColumnMetadata getMetadata() | ||
{ | ||
return metadata; | ||
} | ||
|
||
@Override | ||
public String toString() | ||
{ | ||
return name + "::" + type; | ||
} | ||
|
||
public ColumnInfo withComment(Optional<String> comment) | ||
{ | ||
return new ColumnInfo(handle, ColumnMetadata.builderFrom(metadata) | ||
.setComment(comment) | ||
.build()); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
plugin/trino-faker/src/main/java/io/trino/plugin/faker/FakerColumnHandle.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* 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 io.trino.plugin.faker; | ||
|
||
import io.trino.spi.connector.ColumnHandle; | ||
import io.trino.spi.type.Type; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
|
||
public record FakerColumnHandle( | ||
int columnIndex, | ||
String name, | ||
Type type, | ||
double nullProbability, | ||
String generator) | ||
implements ColumnHandle | ||
{ | ||
public FakerColumnHandle | ||
{ | ||
requireNonNull(name, "name is null"); | ||
requireNonNull(type, "type is null"); | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
plugin/trino-faker/src/main/java/io/trino/plugin/faker/FakerConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* 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 io.trino.plugin.faker; | ||
|
||
import io.airlift.configuration.Config; | ||
import io.airlift.configuration.ConfigDescription; | ||
import jakarta.validation.constraints.Max; | ||
import jakarta.validation.constraints.Min; | ||
|
||
public class FakerConfig | ||
{ | ||
private double nullProbability = 0.5; | ||
private long defaultLimit = 1000L; | ||
|
||
@Max(1) | ||
@Min(0) | ||
public double getNullProbability() | ||
{ | ||
return nullProbability; | ||
} | ||
|
||
@Config("faker.null-probability") | ||
@ConfigDescription("Default null probability for any column in any table that allows them") | ||
public FakerConfig setNullProbability(double value) | ||
{ | ||
this.nullProbability = value; | ||
return this; | ||
} | ||
|
||
@Min(1) | ||
public long getDefaultLimit() | ||
{ | ||
return defaultLimit; | ||
} | ||
|
||
@Config("faker.default-limit") | ||
@ConfigDescription("Default number of rows for each table, when the LIMIT clause is not specified in the query") | ||
public FakerConfig setDefaultLimit(long value) | ||
{ | ||
this.defaultLimit = value; | ||
return this; | ||
} | ||
} |
Oops, something went wrong.