Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 33 additions & 35 deletions mariadb-plugin/docs/Mariadb-batchsink.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,41 +60,39 @@ connections.

Data Types Mapping
----------
+--------------------------------+-----------------------+------------------------------------+
| MariaDB Data Type | CDAP Schema Data Type | Comment |
+--------------------------------+-----------------------+------------------------------------+
| TINYINT | int | |
| BOOLEAN, BOOL | boolean | |
| SMALLINT | int | |
| MEDIUMINT | int | |
| INT, INTEGER | int | |
| BIGINT | long | |
| DECIMAL, DEC, NUMERIC, FIXED | decimal | |
| FLOAT | float | |
| DOUBLE, DOUBLE PRECISION, REAL | decimal | |
| BIT | boolean | |
| CHAR | string | |
| VARCHAR | string | |
| BINARY | bytes | |
| CHAR BYTE | bytes | |
| VARBINARY | bytes | |
| TINYBLOB | bytes | |
| BLOB | bytes | |
| MEDIUMBLOB | bytes | |
| LONGBLOB | bytes | |
| TINYTEXT | string | |
| TEXT | string | |
| MEDIUMTEXT | string | |
| LONGTEXT | string | |
| JSON | string | In MariaDB it is alias to LONGTEXT |
| ENUM | string | Mapping to String by default |
| SET | string | |
| DATE | date | |
| TIME | time_micros | |
| DATETIME | timestamp_micros | |
| TIMESTAMP | timestamp_micros | |
| YEAR | date | |
+--------------------------------+-----------------------+------------------------------------+
| MariaDB Data Type | CDAP Schema Data Type | Comment |
|--------------------------------|-----------------------|---------------------------------------------------------|
| TINYINT | int | |
| BOOLEAN, BOOL | boolean | |
| SMALLINT | int | |
| MEDIUMINT | int | |
| INT, INTEGER | int | |
| BIGINT | long | |
| DECIMAL, DEC, NUMERIC, FIXED | decimal | |
| FLOAT | float | |
| DOUBLE, DOUBLE PRECISION, REAL | decimal | |
| BIT | boolean | |
| CHAR | string | |
| VARCHAR | string | |
| BINARY | bytes | |
| CHAR BYTE | bytes | |
| VARBINARY | bytes | |
| TINYBLOB | bytes | |
| BLOB | bytes | |
| MEDIUMBLOB | bytes | |
| LONGBLOB | bytes | |
| TINYTEXT | string | |
| TEXT | string | |
| MEDIUMTEXT | string | |
| LONGTEXT | string | |
| JSON | string | In MariaDB it is alias to LONGTEXT |
| ENUM | string | Mapping to String by default |
| SET | string | |
| DATE | date | |
| TIME | time_micros | |
| DATETIME | timestamp_micros | |
| TIMESTAMP | timestamp_micros | |
| YEAR | int | Users can manually set output schema to map it to Date. |

Example
-------
Expand Down
70 changes: 33 additions & 37 deletions mariadb-plugin/docs/Mariadb-batchsource.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,43 +78,39 @@ with the tradeoff of higher memory usage.

Data Types Mapping
----------

+--------------------------------+-----------------------+------------------------------------+
| MariaDB Data Type | CDAP Schema Data Type | Comment |
+--------------------------------+-----------------------+------------------------------------+
| TINYINT | int | |
| BOOLEAN, BOOL | boolean | |
| SMALLINT | int | |
| MEDIUMINT | int | |
| INT, INTEGER | int | |
| BIGINT | long | |
| DECIMAL, DEC, NUMERIC, FIXED | decimal | |
| FLOAT | float | |
| DOUBLE, DOUBLE PRECISION, REAL | decimal | |
| BIT | boolean | |
| CHAR | string | |
| VARCHAR | string | |
| BINARY | bytes | |
| CHAR BYTE | bytes | |
| VARBINARY | bytes | |
| TINYBLOB | bytes | |
| BLOB | bytes | |
| MEDIUMBLOB | bytes | |
| LONGBLOB | bytes | |
| TINYTEXT | string | |
| TEXT | string | |
| MEDIUMTEXT | string | |
| LONGTEXT | string | |
| JSON | string | In MariaDB it is alias to LONGTEXT |
| ENUM | string | Mapping to String by default |
| SET | string | |
| DATE | date | |
| TIME | time_micros | |
| DATETIME | timestamp_micros | |
| TIMESTAMP | timestamp_micros | |
| YEAR | date | |
+--------------------------------+-----------------------+------------------------------------+

| MariaDB Data Type | CDAP Schema Data Type | Comment |
|--------------------------------|-----------------------|---------------------------------------------------------|
| TINYINT | int | |
| BOOLEAN, BOOL | boolean | |
| SMALLINT | int | |
| MEDIUMINT | int | |
| INT, INTEGER | int | |
| BIGINT | long | |
| DECIMAL, DEC, NUMERIC, FIXED | decimal | |
| FLOAT | float | |
| DOUBLE, DOUBLE PRECISION, REAL | decimal | |
| BIT | boolean | |
| CHAR | string | |
| VARCHAR | string | |
| BINARY | bytes | |
| CHAR BYTE | bytes | |
| VARBINARY | bytes | |
| TINYBLOB | bytes | |
| BLOB | bytes | |
| MEDIUMBLOB | bytes | |
| LONGBLOB | bytes | |
| TINYTEXT | string | |
| TEXT | string | |
| MEDIUMTEXT | string | |
| LONGTEXT | string | |
| JSON | string | In MariaDB it is alias to LONGTEXT |
| ENUM | string | Mapping to String by default |
| SET | string | |
| DATE | date | |
| TIME | time_micros | |
| DATETIME | timestamp_micros | |
| TIMESTAMP | timestamp_micros | |
| YEAR | int | Users can manually set output schema to map it to Date. |

Example
------
Expand Down
5 changes: 5 additions & 0 deletions mariadb-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@
<version>RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.cdap.plugin</groupId>
<artifactId>mysql-plugin</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright © 2025 Cask Data, Inc.
*
* 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.cdap.plugin.mariadb;

import io.cdap.cdap.api.data.format.StructuredRecord;
import io.cdap.plugin.db.ColumnType;
import io.cdap.plugin.mysql.MysqlDBRecord;
import java.util.List;

/**
* Writable class for MariaDB Source/Sink.
*/
public class MariadbDBRecord extends MysqlDBRecord {

/**
* Used in map-reduce. Do not remove.
*/
@SuppressWarnings("unused")
public MariadbDBRecord() {
// Required by Hadoop DBRecordReader to create an instance
}

public MariadbDBRecord(StructuredRecord record, List<ColumnType> columnTypes) {
super(record, columnTypes);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright © 2025 Cask Data, Inc.
*
* 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.cdap.plugin.mariadb;


import io.cdap.plugin.mysql.MysqlSchemaReader;
import java.util.Map;

/**
* Schema reader for mapping Maria DB type
*/
public class MariadbSchemaReader extends MysqlSchemaReader {

public MariadbSchemaReader (String sessionID) {
super(sessionID);
}

public MariadbSchemaReader (String sessionID, Map<String, String> connectionArguments) {
super(sessionID, connectionArguments);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,14 @@
import io.cdap.cdap.api.annotation.Description;
import io.cdap.cdap.api.annotation.Name;
import io.cdap.cdap.api.annotation.Plugin;
import io.cdap.cdap.api.data.format.StructuredRecord;
import io.cdap.cdap.etl.api.batch.BatchSink;
import io.cdap.plugin.db.DBRecord;
import io.cdap.plugin.db.SchemaReader;
import io.cdap.plugin.db.config.DBSpecificSinkConfig;
import io.cdap.plugin.db.sink.AbstractDBSink;

import io.cdap.plugin.mysql.MysqlDBRecord;
import java.util.Map;
import javax.annotation.Nullable;

Expand All @@ -45,6 +49,17 @@ public MariadbSink(MariadbSinkConfig mariadbSinkConfig) {
this.mariadbSinkConfig = mariadbSinkConfig;
}

@Override
protected DBRecord getDBRecord(StructuredRecord output) {
return new MariadbDBRecord(output, columnTypes);
}

@Override
protected SchemaReader getSchemaReader() {
return new MariadbSchemaReader(null);
}


/**
* MariaDB Sink Config.
*/
Expand Down
Loading
Loading