embulk-output-jdbc
embulk-output-jdbc copied to clipboard
[MySQL] Invalid size for column type bit(0)
For the column type tinyint(1) , the first execution changes to boolean, and the second execution changes to bit(0).
- macOS 10.14.6
- Embulk 0.9.19
- embulk-output-mysql 0.8.6
- MySQL 5.7.21
# example table and column
show columns from payment_logs;
...
is_sample: tinyint(1)
...
first time:
SQL: CREATE TABLE `payment_logs_0000016db361e8a3_embulk000` (`id` BIGINT, `is_sample` BOOLEAN, `created_at` DATETIME, `updated_at` DATETIME)
No errors.
second time:
SQL: CREATE TABLE `payment_logs_0000016db361e8a3_embulk000` (`id` BIGINT, `is_sample` BIT(0), `created_at` DATETIME, `updated_at` DATETIME)
org.embulk.exec.PartialExecutionException: java.lang.RuntimeException: org.embulk.spi.util.RetryExecutor$RetryGiveupException: java.sql.SQLException: Invalid size for column 'is_sample'.
config:
in:
{% if env.ENVIRONMENT == "production" %}
{% include 'commons/input/production' %}
{% else %}
{% include 'commons/input/development' %}
{% endif %}
table: payment_logs
select: "*"
out:
{% if env.ENVIRONMENT == "production" %}
{% include 'commons/output/production' %}
{% else %}
{% include 'commons/output/development' %}
{% endif %}
table: payment_logs
select: "*"
mode: merge
I would like to fix it like the example below.
out:
...
column_options:
is_sample: { type: TINYINT }
Is this a bug?
@yuta17
At the first time, embulk-output-jdbc would create new table because the target table didn't exist.
And because input type for is_sample might be boolean, embulk-output-jdbc created the columns as BOOLEAN.
At the second time, embulk-output-jdbc would create intermediate tables based on the schema of the table created above.
Because MySQL JDBC driver returns BIT as column type and 0 as column size for TINYINT(1), embulk-output-jdbc would try to create a column as BIT(0).
(Maybe because JDBC BIT type represents boolean, although MySQL BIT type is numeric.)
It is not difficult to support MySQL TINYINT(1) (BOOLEAN) type. I'll implement before long.
one more workaround is tinyInt1isBit JDBC option.
out:
...
options: { tinyInt1isBit: false }
https://github.com/embulk/embulk-input-jdbc/issues/53