-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Add MariaDB connector #10046
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
Merged
Merged
Add MariaDB connector #10046
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,162 @@ | ||
| ================= | ||
| MariaDB connector | ||
| ================= | ||
|
|
||
| The MariaDB connector allows querying and | ||
| creating tables in an external MariaDB database. | ||
|
|
||
| Requirements | ||
| ------------ | ||
|
|
||
| To connect to MariaDB, you need: | ||
|
|
||
| * MariaDB version 10.2 or higher. | ||
| * Network access from the Trino coordinator and workers to MariaDB. Port | ||
| 3306 is the default port. | ||
|
|
||
| Configuration | ||
| ------------- | ||
|
|
||
| To configure the MariaDB connector, create a catalog properties file | ||
| in ``etc/catalog`` named, for example, ``mariadb.properties``, to | ||
| mount the MariaDB connector as the ``mariadb`` catalog. | ||
| Create the file with the following contents, replacing the | ||
| connection properties as appropriate for your setup: | ||
|
|
||
| .. code-block:: text | ||
|
|
||
| connector.name=mariadb | ||
| connection-url=jdbc:mariadb://example.net:3306 | ||
| connection-user=root | ||
| connection-password=secret | ||
|
|
||
| .. include:: jdbc-common-configurations.fragment | ||
|
|
||
| .. include:: jdbc-case-insensitive-matching.fragment | ||
|
|
||
| .. include:: non-transactional-insert.fragment | ||
|
|
||
| Querying MariaDB | ||
| ---------------- | ||
|
|
||
| The MariaDB connector provides a schema for every MariaDB *database*. | ||
| You can see the available MariaDB databases by running ``SHOW SCHEMAS``:: | ||
|
|
||
| SHOW SCHEMAS FROM mariadb; | ||
|
|
||
| If you have a MariaDB database named ``web``, you can view the tables | ||
| in this database by running ``SHOW TABLES``:: | ||
|
|
||
| SHOW TABLES FROM mariadb.web; | ||
|
|
||
| You can see a list of the columns in the ``clicks`` table in the ``web`` | ||
| database using either of the following:: | ||
|
|
||
| DESCRIBE mariadb.web.clicks; | ||
| SHOW COLUMNS FROM mariadb.web.clicks; | ||
|
|
||
| Finally, you can access the ``clicks`` table in the ``web`` database:: | ||
|
|
||
| SELECT * FROM mariadb.web.clicks; | ||
|
|
||
| If you used a different name for your catalog properties file, use | ||
| that catalog name instead of ``mariadb`` in the above examples. | ||
|
|
||
| .. mariadb-type-mapping: | ||
|
|
||
| Type mapping | ||
| ------------ | ||
|
|
||
| Trino supports the following MariaDB data types: | ||
|
|
||
| ================================== =============================== | ||
| MariaDB Type Trino Type | ||
| ================================== =============================== | ||
| ``boolean`` ``tinyint`` | ||
| ``tinyint`` ``tinyint`` | ||
| ``smallint`` ``smallint`` | ||
| ``int`` ``integer`` | ||
| ``bigint`` ``bigint`` | ||
|
hashhar marked this conversation as resolved.
Outdated
|
||
| ``tinyint unsigned`` ``smallint`` | ||
| ``smallint unsigned`` ``integer`` | ||
| ``mediumint unsigned`` ``integer`` | ||
| ``integer unsigned`` ``bigint`` | ||
| ``bigint unsigned`` ``decimal(20,0)`` | ||
| ``float`` ``real`` | ||
| ``double`` ``double`` | ||
|
hashhar marked this conversation as resolved.
Outdated
|
||
| ``decimal(p,s)`` ``decimal(p,s)`` | ||
| ``char(n)`` ``char(n)`` | ||
| ``tinytext`` ``varchar(255)`` | ||
| ``text`` ``varchar(65535)`` | ||
| ``mediumtext`` ``varchar(16777215)`` | ||
| ``longtext`` ``varchar`` | ||
| ``varchar(n)`` ``varchar(n)`` | ||
| ``tinyblob`` ``varbinary`` | ||
| ``blob`` ``varbinary`` | ||
| ``mediumblob`` ``varbinary`` | ||
| ``longblob`` ``varbinary`` | ||
| ``varbinary(n)`` ``varbinary`` | ||
| ``date`` ``date`` | ||
| ``time(n)`` ``time(n)`` | ||
| ================================== =============================== | ||
|
|
||
| Complete list of `MariaDB data types | ||
| <https://mariadb.com/kb/en/data-types/>`_. | ||
|
|
||
|
|
||
| .. include:: jdbc-type-mapping.fragment | ||
|
|
||
| .. _mariadb-sql-support: | ||
|
|
||
| SQL support | ||
| ----------- | ||
|
|
||
| The connector provides read access and write access to data and metadata in | ||
| a MariaDB database. In addition to the :ref:`globally available | ||
| <sql-globally-available>` and :ref:`read operation <sql-read-operations>` | ||
| statements, the connector supports the following features: | ||
|
|
||
| * :doc:`/sql/insert` | ||
| * :doc:`/sql/delete` | ||
| * :doc:`/sql/truncate` | ||
| * :doc:`/sql/create-table` | ||
| * :doc:`/sql/create-table-as` | ||
| * :doc:`/sql/drop-table` | ||
| * :doc:`/sql/alter-table` | ||
| * :doc:`/sql/create-schema` | ||
| * :doc:`/sql/drop-schema` | ||
|
|
||
| .. include:: sql-delete-limitation.fragment | ||
|
|
||
| Performance | ||
| ----------- | ||
|
|
||
| The connector includes a number of performance improvements, detailed in the | ||
| following sections. | ||
|
|
||
| .. _mariadb-pushdown: | ||
|
|
||
| Pushdown | ||
| ^^^^^^^^ | ||
|
|
||
| The connector supports pushdown for a number of operations: | ||
|
|
||
| * :ref:`join-pushdown` | ||
| * :ref:`limit-pushdown` | ||
| * :ref:`topn-pushdown` | ||
|
|
||
| :ref:`Aggregate pushdown <aggregation-pushdown>` for the following functions: | ||
|
|
||
| * :func:`avg` | ||
| * :func:`count` | ||
| * :func:`max` | ||
| * :func:`min` | ||
| * :func:`sum` | ||
| * :func:`stddev` | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we list aliases together with the original function name? Pre-existing, would need change in all connectors. |
||
| * :func:`stddev_pop` | ||
| * :func:`stddev_samp` | ||
| * :func:`variance` | ||
| * :func:`var_pop` | ||
| * :func:`var_samp` | ||
|
|
||
| .. include:: no-pushdown-text-type.fragment | ||
This file contains hidden or 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,164 @@ | ||
| <?xml version="1.0"?> | ||
| <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>379-SNAPSHOT</version> | ||
| <relativePath>../../pom.xml</relativePath> | ||
| </parent> | ||
|
|
||
| <artifactId>trino-mariadb</artifactId> | ||
| <description>Trino - MariaDB Connector</description> | ||
| <packaging>trino-plugin</packaging> | ||
|
|
||
| <properties> | ||
| <air.main.basedir>${project.parent.basedir}</air.main.basedir> | ||
| </properties> | ||
|
|
||
| <dependencies> | ||
| <dependency> | ||
| <groupId>io.trino</groupId> | ||
| <artifactId>trino-base-jdbc</artifactId> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>io.trino</groupId> | ||
| <artifactId>trino-plugin-toolkit</artifactId> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>com.google.guava</groupId> | ||
| <artifactId>guava</artifactId> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>com.google.inject</groupId> | ||
| <artifactId>guice</artifactId> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>javax.inject</groupId> | ||
| <artifactId>javax.inject</artifactId> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>org.mariadb.jdbc</groupId> | ||
| <artifactId>mariadb-java-client</artifactId> | ||
| </dependency> | ||
|
|
||
| <!-- used by tests but also needed transitively --> | ||
| <dependency> | ||
| <groupId>io.airlift</groupId> | ||
| <artifactId>log</artifactId> | ||
| <scope>runtime</scope> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>io.airlift</groupId> | ||
| <artifactId>log-manager</artifactId> | ||
| <scope>runtime</scope> | ||
| </dependency> | ||
|
|
||
| <!-- Trino SPI --> | ||
| <dependency> | ||
| <groupId>io.trino</groupId> | ||
| <artifactId>trino-spi</artifactId> | ||
| <scope>provided</scope> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>io.airlift</groupId> | ||
| <artifactId>slice</artifactId> | ||
| <scope>provided</scope> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>com.fasterxml.jackson.core</groupId> | ||
| <artifactId>jackson-annotations</artifactId> | ||
| <scope>provided</scope> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>org.openjdk.jol</groupId> | ||
| <artifactId>jol-core</artifactId> | ||
| <scope>provided</scope> | ||
| </dependency> | ||
|
|
||
| <!-- for testing --> | ||
| <dependency> | ||
| <groupId>io.trino</groupId> | ||
| <artifactId>trino-base-jdbc</artifactId> | ||
| <type>test-jar</type> | ||
| <scope>test</scope> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>io.trino</groupId> | ||
| <artifactId>trino-main</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>io.trino</groupId> | ||
| <artifactId>trino-main</artifactId> | ||
| <type>test-jar</type> | ||
| <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>io.trino.tpch</groupId> | ||
| <artifactId>tpch</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>io.airlift</groupId> | ||
| <artifactId>testing</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>org.assertj</groupId> | ||
| <artifactId>assertj-core</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>org.jetbrains</groupId> | ||
| <artifactId>annotations</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>org.testcontainers</groupId> | ||
| <artifactId>mariadb</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>org.testcontainers</groupId> | ||
| <artifactId>testcontainers</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>org.testng</groupId> | ||
| <artifactId>testng</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| </dependencies> | ||
| </project> |
26 changes: 26 additions & 0 deletions
26
plugin/trino-mariadb/src/main/java/io/trino/plugin/mariadb/ImplementAvgBigint.java
This file contains hidden or 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,26 @@ | ||
| /* | ||
| * 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.mariadb; | ||
|
|
||
| import io.trino.plugin.jdbc.aggregation.BaseImplementAvgBigint; | ||
|
|
||
| public class ImplementAvgBigint | ||
| extends BaseImplementAvgBigint | ||
| { | ||
| @Override | ||
| protected String getRewriteFormatExpression() | ||
| { | ||
| return "avg((%s * 1.0))"; | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.