heavydb icon indicating copy to clipboard operation
heavydb copied to clipboard

".60" is accepted by mapd-server but not in CSV file by LOAD

Open fleapapa opened this issue 9 years ago • 5 comments

A minor issue as title. Numeric strings like ".60" were loaded to become NULLs. In database:

mapdql> select * from trip1; medallion|hack_license|vendor_id|rate_code_id|store_and_fwd_flag|pickup_datetime|dropoff_datetime|passenger_count|trip_time_in_secs|trip_distance|pickup_longitude|pickup_latitude|dropoff_longitude|dropoff_latitude D924885BA122B60895801D9C11191182|F744917D50FC3B78BB0FB960B0BEEE58|CMT|1|N|2013-10-08 10:51:23|2013-10-08 10:55:49|1|266|1.100000|-74.010000|40.710000|-74.000000|40.720000 D924885BA122B60895801D9C11191182|F744917D50FC3B78BB0FB960B0BEEE58|CMT|1|N|2013-10-08 11:06:55|2013-10-08 11:11:22|1|266|NULL|-74.000000|40.710000|-74.000000|40.720000 D924885BA122B60895801D9C11191182|F744917D50FC3B78BB0FB960B0BEEE58|CMT|1|N|2013-10-09 10:03:00|2013-10-09 10:07:27|1|266|NULL|-74.000000|40.730000|-74.000000|40.720000 D924885BA122B60895801D9C11191182|F744917D50FC3B78BB0FB960B0BEEE58|CMT|1|N|2013-11-10 03:21:44|2013-11-10 03:26:11|4|266|1.300000|-73.920000|40.700000|-73.920000|40.690000 595917A7813CC80DAADD7ED0FE98D42C|F744917D50FC3B78BB0FB960B0BEEE58|CMT|1|N|2013-03-09 08:40:30|2013-03-09 08:44:56|1|266|NULL|-74.000000|40.730000|-73.990000|40.720000 595917A7813CC80DAADD7ED0FE98D42C|F744917D50FC3B78BB0FB960B0BEEE58|CMT|1|N|2013-03-24 11:07:36|2013-03-24 11:12:03|2|266|1.000000|-73.980000|40.750000|-73.990000|40.750000 595917A7813CC80DAADD7ED0FE98D42C|F744917D50FC3B78BB0FB960B0BEEE58|CMT|1|N|2013-04-11 12:19:28|2013-04-11 12:23:55|1|266|NULL|-73.980000|40.730000|-73.990000|40.730000

In CSV file:

$ cat /tmp/1.csv D924885BA122B60895801D9C11191182,F744917D50FC3B78BB0FB960B0BEEE58,CMT,1,N,2013-10-08 10:51:23,2013-10-08 10:55:49,1,266,1.10,-74.014816,40.714043,-74.007423,40.725849 D924885BA122B60895801D9C11191182,F744917D50FC3B78BB0FB960B0BEEE58,CMT,1,N,2013-10-08 11:06:55,2013-10-08 11:11:22,1,266,.60,-74.003616,40.717739,-74.008064,40.722805 D924885BA122B60895801D9C11191182,F744917D50FC3B78BB0FB960B0BEEE58,CMT,1,N,2013-10-09 10:03:00,2013-10-09 10:07:27,1,266,.70,-74.002113,40.734909,-74.005547,40.72588 D924885BA122B60895801D9C11191182,F744917D50FC3B78BB0FB960B0BEEE58,CMT,1,N,2013-11-10 03:21:44,2013-11-10 03:26:11,4,266,1.30,-73.926254,40.703239,-73.929527,40.695892 595917A7813CC80DAADD7ED0FE98D42C,F744917D50FC3B78BB0FB960B0BEEE58,CMT,1,N,2013-03-09 08:40:30,2013-03-09 08:44:56,1,266,.60,-74.008095,40.73103,-73.996094,40.729256 595917A7813CC80DAADD7ED0FE98D42C,F744917D50FC3B78BB0FB960B0BEEE58,CMT,1,N,2013-03-24 11:07:36,2013-03-24 11:12:03,2,266,1.00,-73.982224,40.755402,-73.991188,40.750027 595917A7813CC80DAADD7ED0FE98D42C,F744917D50FC3B78BB0FB960B0BEEE58,CMT,1,N,2013-04-11 12:19:28,2013-04-11 12:23:55,1,266,.60,-73.984024,40.738232,-73.991913,40.734459

It seems ".60" is accepted by mapd-server.

I0924 00:20:33.375540 24364 MapDHandler.cpp:555] sql_execute :Jln41glhI3UMYHWnN7gopx490REdwOSF:query_str:select .60 from trips limit 1; I0924 00:20:33.804924 24364 Calcite.cpp:247] User mapd catalog mapd sql 'select .60 from trips limit 1;'

fleapapa avatar Sep 24 '17 07:09 fleapapa

CSV requires a leading 0 Should be a fairly straight forward change to correct, if you have an interest in working on the source.

dwayneberry avatar Sep 24 '17 14:09 dwayneberry

I'm interested but embarrassingly so far i haven't gotten mapd built successfully on my Ubuntu 16.04 Having too much stuff to review these days. Will find time to check out the latest code to rebuild it. Hope it won't break again...

fleapapa avatar Sep 24 '17 15:09 fleapapa

After replacing line Datum.cpp:60 with the following two,

    // make .99 as 0.99, or std::stoll below throws exception 'std::invalid_argument'
    before_dot = (0 == dot)? "0": s.substr(0, dot);

the issue seems gone:

mapdql> select * from trip1; medallion|hack_license|vendor_id|rate_code_id|store_and_fwd_flag|pickup_datetime|dropoff_datetime|passenger_count|trip_time_in_secs|trip_distance|pickup_longitude|pickup_latitude|dropoff_longitude|dropoff_latitude D924885BA122B60895801D9C11191182|F744917D50FC3B78BB0FB960B0BEEE58|CMT|1|N|2013-10-08 10:51:23|2013-10-08 10:55:49|1|266|1.100000|-74.020000|40.710000|-74.010000|40.730000 D924885BA122B60895801D9C11191182|F744917D50FC3B78BB0FB960B0BEEE58|CMT|1|N|2013-10-08 11:06:55|2013-10-08 11:11:22|1|266|0.600000|-74.000000|40.720000|-74.010000|40.720000 D924885BA122B60895801D9C11191182|F744917D50FC3B78BB0FB960B0BEEE58|CMT|1|N|2013-10-09 10:03:00|2013-10-09 10:07:27|1|266|0.700000|-74.000000|40.740000|-74.010000|40.730000 D924885BA122B60895801D9C11191182|F744917D50FC3B78BB0FB960B0BEEE58|CMT|1|N|2013-11-10 03:21:44|2013-11-10 03:26:11|4|266|1.300000|-73.930000|40.700000|-73.930000|40.700000 595917A7813CC80DAADD7ED0FE98D42C|F744917D50FC3B78BB0FB960B0BEEE58|CMT|1|N|2013-03-09 08:40:30|2013-03-09 08:44:56|1|266|0.600000|-74.010000|40.730000|-74.000000|40.730000 595917A7813CC80DAADD7ED0FE98D42C|F744917D50FC3B78BB0FB960B0BEEE58|CMT|1|N|2013-03-24 11:07:36|2013-03-24 11:12:03|2|266|1.000000|-73.980000|40.760000|-73.990000|40.750000 595917A7813CC80DAADD7ED0FE98D42C|F744917D50FC3B78BB0FB960B0BEEE58|CMT|1|N|2013-04-11 12:19:28|2013-04-11 12:23:55|1|266|0.600000|-73.980000|40.740000|-73.990000|40.740000

Guiltily, having used many open source s/w I've never contributed one source code change to any open source project other than my own. What should i do now to merge this change to which mapd-core branch? Use pull request?

fleapapa avatar Sep 24 '17 17:09 fleapapa

Thanks, you will need to complete the contributor process. See repo readme

Then yes you would create a pull request. We will review and push when tested

dwayneberry avatar Sep 24 '17 17:09 dwayneberry

It's fixed by https://github.com/mapd/mapd-core/commit/7f72560680dd3de8c1973073f1a0cd1b5d19e494. We should add an unit test for it as well.

asuhan avatar Sep 26 '17 04:09 asuhan