Skip to content

Instantly share code, notes, and snippets.

@hiroyuki-sato
Last active February 21, 2017 08:17
Show Gist options
  • Save hiroyuki-sato/2a6e54c9281b5650312c2e514749ac9b to your computer and use it in GitHub Desktop.
Save hiroyuki-sato/2a6e54c9281b5650312c2e514749ac9b to your computer and use it in GitHub Desktop.
Postgresql uuid column
embulk preview uuid_test.yml
2017-02-21 16:43:40.105 +0900: Embulk v0.8.17
2017-02-21 16:43:41.594 +0900 [INFO] (0001:preview): Loaded plugin embulk-input-postgresql (0.7.2)
2017-02-21 16:43:41.735 +0900 [INFO] (0001:preview): SQL: SET search_path TO "public"
2017-02-21 16:43:41.760 +0900 [INFO] (0001:preview): SQL: SELECT * FROM "uuid_test"
2017-02-21 16:43:41.866 +0900 [INFO] (0001:preview): SQL: SET search_path TO "public"
2017-02-21 16:43:41.872 +0900 [INFO] (0001:preview): SQL: DECLARE cur NO SCROLL CURSOR FOR SELECT * FROM "uuid_test"
2017-02-21 16:43:41.873 +0900 [INFO] (0001:preview): SQL: FETCH FORWARD 10000 FROM cur
2017-02-21 16:43:41.875 +0900 [INFO] (0001:preview): > 0.00 seconds
2017-02-21 16:43:41.877 +0900 [INFO] (0001:preview): SQL: FETCH FORWARD 10000 FROM cur
2017-02-21 16:43:41.878 +0900 [INFO] (0001:preview): > 0.00 seconds
+---------+--------------------------------------+
| id:long |                          uuid:string |
+---------+--------------------------------------+
|       1 | 217c1340-6aaf-40d8-b449-6e1f605f9ff3 |
|       2 | 395a5f2c-226f-4738-b838-ef669dbbf1b0 |
+---------+--------------------------------------+
in:
  type: postgresql
  host: 127.0.0.1
  user: xxx
  password: xxxx
  database: embulk_test
  table: uuid_test
  column_options:
    uuid: { value_type: string }
out:
  type: stdout
\d+ uuid_test;
                      Table "public.uuid_test"
 Column |  Type   | Modifiers | Storage | Stats target | Description
--------+---------+-----------+---------+--------------+-------------
 id     | integer | not null  | plain   |              |
 uuid   | uuid    | not null  | plain   |              |
 id |                 uuid
----+--------------------------------------
  1 | 217c1340-6aaf-40d8-b449-6e1f605f9ff3
  2 | 395a5f2c-226f-4738-b838-ef669dbbf1b0
(2 rows)
create table uuid_test(id int not null,uuid uuid not null);
insert into uuid_test values(1,'217C1340-6AAF-40D8-B449-6E1F605F9FF3'),(2,'395A5F2C-226F-4738-B838-EF669DBBF1B0');
2017-02-21 17:14:55.758 +0900: Embulk v0.8.17
2017-02-21 17:14:57.464 +0900 [INFO] (0001:preview): Loaded plugin embulk-input-postgresql (0.8.2)
2017-02-21 17:14:57.587 +0900 [INFO] (0001:preview): SQL: SET search_path TO "public"
java.lang.UnsupportedOperationException: Unsupported type uuid (sqlType=1111) of 'uuid' column. Please add 'uuid: {value_type: string}' to 'column_options: {...}' option to convert the values to strings, or exclude the column from 'select:' option
	at org.embulk.input.jdbc.getter.ColumnGetterFactory.unsupportedOperationException(org/embulk/input/jdbc/getter/ColumnGetterFactory.java:189)
	at org.embulk.input.jdbc.getter.ColumnGetterFactory.sqlTypeToValueType(org/embulk/input/jdbc/getter/ColumnGetterFactory.java:163)
	at org.embulk.input.postgresql.getter.PostgreSQLColumnGetterFactory.sqlTypeToValueType(org/embulk/input/postgresql/getter/PostgreSQLColumnGetterFactory.java:54)
	at org.embulk.input.jdbc.getter.ColumnGetterFactory.newColumnGetter(org/embulk/input/jdbc/getter/ColumnGetterFactory.java:44)
	at org.embulk.input.jdbc.getter.ColumnGetterFactory.newColumnGetter(org/embulk/input/jdbc/getter/ColumnGetterFactory.java:35)
	at org.embulk.input.postgresql.getter.PostgreSQLColumnGetterFactory.newColumnGetter(org/embulk/input/postgresql/getter/PostgreSQLColumnGetterFactory.java:30)
	at org.embulk.input.jdbc.AbstractJdbcInputPlugin.newColumnGetters(org/embulk/input/jdbc/AbstractJdbcInputPlugin.java:484)
	at org.embulk.input.jdbc.AbstractJdbcInputPlugin.setupTask(org/embulk/input/jdbc/AbstractJdbcInputPlugin.java:264)
	at org.embulk.input.jdbc.AbstractJdbcInputPlugin.transaction(org/embulk/input/jdbc/AbstractJdbcInputPlugin.java:188)
	at org.embulk.exec.PreviewExecutor.doPreview(org/embulk/exec/PreviewExecutor.java:108)
	at org.embulk.exec.PreviewExecutor.doPreview(org/embulk/exec/PreviewExecutor.java:101)
	at org.embulk.exec.PreviewExecutor.access$000(org/embulk/exec/PreviewExecutor.java:30)
	at org.embulk.exec.PreviewExecutor$1.run(org/embulk/exec/PreviewExecutor.java:70)
	at org.embulk.exec.PreviewExecutor$1.run(org/embulk/exec/PreviewExecutor.java:66)
	at org.embulk.spi.Exec.doWith(org/embulk/spi/Exec.java:25)
	at org.embulk.exec.PreviewExecutor.preview(org/embulk/exec/PreviewExecutor.java:66)
	at org.embulk.EmbulkEmbed.preview(org/embulk/EmbulkEmbed.java:169)
	at java.lang.reflect.Method.invoke(java/lang/reflect/Method.java:498)
	at org.jruby.javasupport.JavaMethod.invokeDirectWithExceptionHandling(org/jruby/javasupport/JavaMethod.java:453)
	at org.jruby.javasupport.JavaMethod.invokeDirect(org/jruby/javasupport/JavaMethod.java:314)
	at RUBY.preview(/Users/hsato/.embulk/bin/embulk!/embulk/runner.rb:35)
	at RUBY.run(/Users/hsato/.embulk/bin/embulk!/embulk/command/embulk_run.rb:305)
	at RUBY.<main>(/Users/hsato/.embulk/bin/embulk!/embulk/command/embulk_main.rb:2)
	at org.jruby.Ruby.runInterpreter(org/jruby/Ruby.java:850)
	at org.jruby.Ruby.loadFile(org/jruby/Ruby.java:2976)
	at org.jruby.RubyKernel.requireCommon(org/jruby/RubyKernel.java:963)
	at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:956)
	at org.jruby.RubyKernel$INVOKER$s$1$0$require19.call(org/jruby/RubyKernel$INVOKER$s$1$0$require19.gen)
	at RUBY.(root)(uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:1)
	at Users.hsato.$_dot_embulk.bin.embulk.embulk.command.embulk_bundle.invokeOther66:require(Users/hsato/$_dot_embulk/bin/embulk/embulk/command/file:/Users/hsato/.embulk/bin/embulk!/embulk/command/embulk_bundle.rb:51)
	at Users.hsato.$_dot_embulk.bin.embulk.embulk.command.embulk_bundle.<main>(file:/Users/hsato/.embulk/bin/embulk!/embulk/command/embulk_bundle.rb:51)
	at java.lang.invoke.MethodHandle.invokeWithArguments(java/lang/invoke/MethodHandle.java:627)
	at org.jruby.Ruby.runScript(org/jruby/Ruby.java:834)
	at org.jruby.Ruby.runNormally(org/jruby/Ruby.java:749)
	at org.jruby.Ruby.runNormally(org/jruby/Ruby.java:767)
	at org.jruby.Ruby.runFromMain(org/jruby/Ruby.java:580)
	at org.jruby.Main.doRunFromMain(org/jruby/Main.java:425)
	at org.jruby.Main.internalRun(org/jruby/Main.java:313)
	at org.jruby.Main.run(org/jruby/Main.java:242)
	at org.jruby.Main.main(org/jruby/Main.java:204)
	at org.embulk.cli.Main.main(org/embulk/cli/Main.java:23)

Error: Unsupported type uuid (sqlType=1111) of 'uuid' column. Please add 'uuid: {value_type: string}' to 'column_options: {...}' option to convert the values to strings, or exclude the column from 'select:' option
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment