undefined method `to_msgpack' for 2015-01-27 19:23:49 UTC:Java::OrgJruby::RubyTime
See original GitHub issueEmbulk version: 0.8.38 and 0.9.1
Original report is here, but I think this is embulk’s problem.
I tried following step with ruby-filter, but I got an exception “undefined method `to_msgpack’ for 2015-01-27 19:23:49 UTC:Java::OrgJruby::RubyTime”
mkdir work
cd work
embulk example
embulk guess */seed.yml -o config.yml
embulk new ruby-filter sample
cat <<END >> config.yml
filters:
- type: sample
option1: 1
END
embulk -I./embulk-filter-sample/lib preview config.yml
I got a following exception:
org.jruby.exceptions.RaiseException: (NoMethodError) undefined method `to_msgpack' for 2015-01-27 19:23:49 UTC:Java::OrgJruby::RubyTime
at RUBY.set(uri:classloader:/gems/embulk-0.9.1-java/lib/embulk/page_builder.rb:21)
at RUBY.add(uri:classloader:/gems/embulk-0.9.1-java/lib/embulk/page_builder.rb:53)
at RUBY.block in add(/Users/koji/work/work/embulk-filter-sample/lib/embulk/filter/sample.rb:40)
at RUBY.each(uri:classloader:/gems/embulk-0.9.1-java/lib/embulk/page.rb:22)
at RUBY.add(/Users/koji/work/work/embulk-filter-sample/lib/embulk/filter/sample.rb:39)
at RUBY.add(uri:classloader:/gems/embulk-0.9.1-java/lib/embulk/filter_plugin.rb:78)
at RUBY.block in transaction(uri:classloader:/gems/embulk-0.9.1-java/lib/embulk/filter_plugin.rb:54)
at RUBY.transaction(/Users/koji/work/work/embulk-filter-sample/lib/embulk/filter/sample.rb:23)
at RUBY.transaction(uri:classloader:/gems/embulk-0.9.1-java/lib/embulk/filter_plugin.rb:51)
This is because embulk pass the Java::OrgJruby::RubyTime object instead of Time object.
If I apply following patch to embulk, this problem is solved.
patch is here:
--- embulk-0.9.1/gems/embulk-0.9.1-java/lib/embulk/schema.rb.orig 2018-02-11 11:14:24.000000000 +0900
+++ embulk-0.9.1/gems/embulk-0.9.1-java/lib/embulk/schema.rb 2018-02-11 11:14:46.000000000 +0900
@@ -36,7 +36,7 @@
# Constructor of `org.jruby.RubyTime` requires `org.joda.time.DateTime`.
# http://jruby.org/apidocs/org/jruby/RubyTime.html#RubyTime(org.jruby.Ruby,%20org.jruby.RubyClass,%20org.joda.time.DateTime)
# TODO: Replace `RubyTime.new` to `RubyTime.newTime`.
- "record << (java_timestamp = reader.getTimestamp(#{idx}); ruby_time = Java::org.jruby.RubyTime.new(JRuby.runtime, JRuby.runtime.getClass('Time'), Java::org.joda.time.DateTime.new(java_timestamp.toEpochMilli())).gmtime().to_java(Java::org.jruby.RubyTime); ruby_time.setNSec(java_timestamp.getNano()); ruby_time)"
+ "record << (java_timestamp = reader.getTimestamp(#{idx}); ruby_time = Java::org.jruby.RubyTime.new(JRuby.runtime, JRuby.runtime.getClass('Time'), Java::org.joda.time.DateTime.new(java_timestamp.toEpochMilli())).gmtime().to_java(Java::org.jruby.RubyTime); ruby_time.setNSec(java_timestamp.getNano()); ruby_time.gmtime)"
when :json
"record << MessagePack.unpack(String.from_java_bytes((::Java::org.msgpack.core.MessagePack.newDefaultBufferPacker()).packValue(reader.getJson(#{idx})).toMessageBuffer().toByteArray()))"
else
unzip -d embulk-0.9.1 ~/.embulk/bin/embulk
patch embulk-0.9.1/gems/embulk-0.9.1-java/lib/embulk/schema.rb above.patch
java -classpath ./embulk-0.9.1 org.embulk.cli.Main -I./embulk-filter-sample/lib preview config.yml
+---------+--------------+-------------------------+-------------------------+----------------------------+----------------+-------------+--------------+
| id:long | account:long | time:timestamp | purchase:timestamp | comment:string | example:string | column:long | value:double |
+---------+--------------+-------------------------+-------------------------+----------------------------+----------------+-------------+--------------+
| 1 | 32,864 | 2015-01-27 19:23:49 UTC | 2015-01-27 00:00:00 UTC | embulk | example | 1 | 1.0 |
| 2 | 14,824 | 2015-01-27 19:01:23 UTC | 2015-01-27 00:00:00 UTC | embulk jruby | example | 1 | 1.0 |
| 3 | 27,559 | 2015-01-28 02:20:02 UTC | 2015-01-28 00:00:00 UTC | Embulk "csv" parser plugin | example | 1 | 1.0 |
| 4 | 11,270 | 2015-01-29 11:54:36 UTC | 2015-01-29 00:00:00 UTC | | example | 1 | 1.0 |
+---------+--------------+-------------------------+-------------------------+----------------------------+----------------+-------------+--------------+
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
No results found
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@jca02266 Embulk v0.9.4 has been released! 😃
Thanks a lot!