You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@phoenix.apache.org by ndimiduk <gi...@git.apache.org> on 2015/12/02 20:36:01 UTC

[GitHub] phoenix pull request: PHOENIX-2481 JSON bulkload tool

GitHub user ndimiduk opened a pull request:

    https://github.com/apache/phoenix/pull/141

    PHOENIX-2481 JSON bulkload tool

    

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/ndimiduk/phoenix 2481-json-bulkload-tool

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/phoenix/pull/141.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #141
    
----
commit 1a4a511b4f4f2d7e8c1cf212f9558bf8aab88f19
Author: Nick Dimiduk <nd...@apache.org>
Date:   2015-11-17T01:18:34Z

    PHOENIX-2481 JSON bulkload tool

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] phoenix issue #141: PHOENIX-2481 JSON bulkload tool

Posted by nagarjunak758 <gi...@git.apache.org>.
Github user nagarjunak758 commented on the issue:

    https://github.com/apache/phoenix/pull/141
  
    Would be great if the apache phoenix documentation is also updated, possibly with some examples.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] phoenix pull request: PHOENIX-2481 JSON bulkload tool

Posted by JamesRTaylor <gi...@git.apache.org>.
Github user JamesRTaylor commented on the pull request:

    https://github.com/apache/phoenix/pull/141#issuecomment-161471331
  
    Awesome, @ndimiduk - I love it. Couple of questions and some nits:
    - For JSON, is only single level supported? If not, how is nested JSON handled?
    - Looks like lists are converted into ARRAYs which is nice. What happens if the array elements have different data types? I guess you'd just log an error and ignore that row?
    - Can you make sure the indenting conforms to the 4 space convention?
    - Also, please make sure imports don't use * and that their order is correct (see dev/phoenix.importorder and dev/eclipse_prefs_phoenix.epf).
    
    @gabrielreid - got a few spare cycles for a review?



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] phoenix issue #141: PHOENIX-2481 JSON bulkload tool

Posted by nagarjunak758 <gi...@git.apache.org>.
Github user nagarjunak758 commented on the issue:

    https://github.com/apache/phoenix/pull/141
  
    Would be great if the documentation is updated, possibly with few examples.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] phoenix pull request: PHOENIX-2481 JSON bulkload tool

Posted by ndimiduk <gi...@git.apache.org>.
Github user ndimiduk commented on the pull request:

    https://github.com/apache/phoenix/pull/141#issuecomment-161410084
  
    Add a tool for loading json documents (one record per line) and refactor code in common between JSON and CSV loading.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] phoenix pull request: PHOENIX-2481 JSON bulkload tool

Posted by ndimiduk <gi...@git.apache.org>.
Github user ndimiduk commented on the pull request:

    https://github.com/apache/phoenix/pull/141#issuecomment-162033375
  
    > For JSON, is only single level supported? If not, how is nested JSON handled?
    
    No special handling is provided. A nested json object will be read as Map and presented to the upsert statement as such. Since Phoenix doesn't support maps, an error would result.
    
    > Looks like lists are converted into ARRAYs which is nice. What happens if the array elements have different data types? I guess you'd just log an error and ignore that row?
    
    Indeed. Or fail the job, if `--ignore-errors` is not specified.
    
    > Can you make sure the indenting conforms to the 4 space convention?
    
    Pardon me, @JamesRTaylor. Done.
    
    > Also, please make sure imports don't use * and that their order is correct
    
    Done.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] phoenix pull request: PHOENIX-2481 JSON bulkload tool

Posted by ndimiduk <gi...@git.apache.org>.
Github user ndimiduk commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/141#discussion_r46853590
  
    --- Diff: phoenix-core/src/main/java/org/apache/phoenix/mapreduce/JsonBulkLoadTool.java ---
    @@ -0,0 +1,53 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + * http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.phoenix.mapreduce;
    +
    +import java.sql.SQLException;
    +import java.util.List;
    +
    +import org.apache.commons.cli.CommandLine;
    +import org.apache.hadoop.conf.Configuration;
    +import org.apache.hadoop.mapreduce.Job;
    +import org.apache.hadoop.util.ToolRunner;
    +import org.apache.phoenix.util.ColumnInfo;
    +
    +/**
    + * Base tool for running MapReduce-based ingests of data.
    --- End diff --
    
    done.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] phoenix pull request: PHOENIX-2481 JSON bulkload tool

Posted by JamesRTaylor <gi...@git.apache.org>.
Github user JamesRTaylor commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/141#discussion_r46779469
  
    --- Diff: phoenix-core/src/main/java/org/apache/phoenix/mapreduce/JsonBulkLoadTool.java ---
    @@ -0,0 +1,53 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + * http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.phoenix.mapreduce;
    +
    +import java.sql.SQLException;
    +import java.util.List;
    +
    +import org.apache.commons.cli.CommandLine;
    +import org.apache.hadoop.conf.Configuration;
    +import org.apache.hadoop.mapreduce.Job;
    +import org.apache.hadoop.util.ToolRunner;
    +import org.apache.phoenix.util.ColumnInfo;
    +
    +/**
    + * Base tool for running MapReduce-based ingests of data.
    --- End diff --
    
    Tool for running MapReduce-based ingests of JSON data.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] phoenix pull request: PHOENIX-2481 JSON bulkload tool

Posted by JamesRTaylor <gi...@git.apache.org>.
Github user JamesRTaylor commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/141#discussion_r46779479
  
    --- Diff: phoenix-core/src/main/java/org/apache/phoenix/mapreduce/JsonBulkLoadTool.java ---
    @@ -0,0 +1,53 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + * http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.phoenix.mapreduce;
    +
    +import java.sql.SQLException;
    +import java.util.List;
    +
    +import org.apache.commons.cli.CommandLine;
    +import org.apache.hadoop.conf.Configuration;
    +import org.apache.hadoop.mapreduce.Job;
    +import org.apache.hadoop.util.ToolRunner;
    +import org.apache.phoenix.util.ColumnInfo;
    +
    +/**
    + * Base tool for running MapReduce-based ingests of data.
    --- End diff --
    
    Nested JSON data is not handled and lists are converted to ARRAYs.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] phoenix issue #141: PHOENIX-2481 JSON bulkload tool

Posted by JamesRTaylor <gi...@git.apache.org>.
Github user JamesRTaylor commented on the issue:

    https://github.com/apache/phoenix/pull/141
  
    Thanks for the feedback, @nagarjunak758. I've added a mention of the JSON bulk loader in our Bulk Loading page here: https://phoenix.apache.org/bulk_dataload.html. Please feel free to send us a patch with additional information/examples. The information on how to do that is here: https://phoenix.apache.org/building_website.html


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] phoenix pull request: PHOENIX-2481 JSON bulkload tool

Posted by gabrielreid <gi...@git.apache.org>.
Github user gabrielreid commented on the pull request:

    https://github.com/apache/phoenix/pull/141#issuecomment-162239436
  
    Very cool, looks good! I noted a few small nits in the commit, but apart from that it all looks good to me.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] phoenix pull request: PHOENIX-2481 JSON bulkload tool

Posted by ndimiduk <gi...@git.apache.org>.
Github user ndimiduk commented on the pull request:

    https://github.com/apache/phoenix/pull/141#issuecomment-162108877
  
    Okay. Went through all javadocs. Also rebased onto master.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] phoenix pull request: PHOENIX-2481 JSON bulkload tool

Posted by joshelser <gi...@git.apache.org>.
Github user joshelser commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/141#discussion_r46732160
  
    --- Diff: phoenix-core/src/main/java/org/apache/phoenix/mapreduce/FormatToKeyValueMapper.java ---
    @@ -0,0 +1,254 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + * http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.phoenix.mapreduce;
    +
    +import java.io.IOException;
    +import java.sql.SQLException;
    +import java.util.Iterator;
    +import java.util.List;
    +import java.util.Map;
    +import java.util.Properties;
    +import javax.annotation.Nullable;
    +
    +import org.apache.hadoop.conf.Configuration;
    +import org.apache.hadoop.hbase.KeyValue;
    +import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
    +import org.apache.hadoop.hbase.util.Bytes;
    +import org.apache.hadoop.hbase.util.Pair;
    +import org.apache.hadoop.io.LongWritable;
    +import org.apache.hadoop.io.Text;
    +import org.apache.hadoop.mapreduce.Mapper;
    +import org.apache.phoenix.jdbc.PhoenixConnection;
    +import org.apache.phoenix.mapreduce.bulkload.TableRowkeyPair;
    +import org.apache.phoenix.mapreduce.bulkload.TargetTableRefFunctions;
    +import org.apache.phoenix.mapreduce.util.PhoenixConfigurationUtil;
    +import org.apache.phoenix.util.ColumnInfo;
    +import org.apache.phoenix.util.PhoenixRuntime;
    +import org.apache.phoenix.util.QueryUtil;
    +import org.apache.phoenix.util.UpsertExecutor;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import com.google.common.annotations.VisibleForTesting;
    +import com.google.common.base.Function;
    +import com.google.common.base.Joiner;
    +import com.google.common.base.Splitter;
    +import com.google.common.base.Throwables;
    +import com.google.common.collect.ImmutableList;
    +import com.google.common.collect.Iterables;
    +import com.google.common.collect.Lists;
    +
    +public abstract class FormatToKeyValueMapper<RECORD> extends Mapper<LongWritable, Text, TableRowkeyPair,
    --- End diff --
    
    Some javadocs would be nice :)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] phoenix pull request: PHOENIX-2481 JSON bulkload tool

Posted by JamesRTaylor <gi...@git.apache.org>.
Github user JamesRTaylor commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/141#discussion_r46779456
  
    --- Diff: phoenix-core/src/main/java/org/apache/phoenix/mapreduce/JsonToKeyValueMapper.java ---
    @@ -0,0 +1,75 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + * http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.phoenix.mapreduce;
    +
    +import java.io.IOException;
    +import java.util.List;
    +import java.util.Map;
    +
    +import org.apache.hadoop.conf.Configuration;
    +import org.apache.phoenix.util.ColumnInfo;
    +import org.apache.phoenix.util.UpsertExecutor;
    +import org.apache.phoenix.util.json.JsonUpsertExecutor;
    +import org.codehaus.jackson.map.ObjectMapper;
    +
    +import com.google.common.annotations.VisibleForTesting;
    +import com.google.common.base.Preconditions;
    +
    +/**
    + * MapReduce mapper that converts CSV input lines into KeyValues that can be written to HFiles.
    --- End diff --
    
    CSV -> JSON


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] phoenix pull request: PHOENIX-2481 JSON bulkload tool

Posted by ndimiduk <gi...@git.apache.org>.
Github user ndimiduk commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/141#discussion_r46853357
  
    --- Diff: phoenix-core/src/main/java/org/apache/phoenix/mapreduce/JsonToKeyValueMapper.java ---
    @@ -0,0 +1,75 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + * http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.phoenix.mapreduce;
    +
    +import java.io.IOException;
    +import java.util.List;
    +import java.util.Map;
    +
    +import org.apache.hadoop.conf.Configuration;
    +import org.apache.phoenix.util.ColumnInfo;
    +import org.apache.phoenix.util.UpsertExecutor;
    +import org.apache.phoenix.util.json.JsonUpsertExecutor;
    +import org.codehaus.jackson.map.ObjectMapper;
    +
    +import com.google.common.annotations.VisibleForTesting;
    +import com.google.common.base.Preconditions;
    +
    +/**
    + * MapReduce mapper that converts CSV input lines into KeyValues that can be written to HFiles.
    --- End diff --
    
    Done.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---