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

[MySQL] Invalid size for column type bit(0) #263

Open
yuta17 opened this issue Oct 10, 2019 · 1 comment
Open

[MySQL] Invalid size for column type bit(0) #263

yuta17 opened this issue Oct 10, 2019 · 1 comment

Comments

@yuta17
Copy link

@yuta17 yuta17 commented Oct 10, 2019

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?

@hito4t

This comment has been minimized.

Copy link
Contributor

@hito4t hito4t commented Oct 11, 2019

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.