├── doc └── source │ └── images │ ├── schema.png │ └── architecture.png ├── scripts ├── import_data.txt ├── query_table.txt └── create_table.txt ├── ACKNOWLEDGEMENTS.md ├── CONTRIBUTING.md ├── MAINTAINERS.md ├── LICENSE ├── README.md └── data └── store_sales.txt /doc/source/images/schema.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/sparksql-for-hbase/HEAD/doc/source/images/schema.png -------------------------------------------------------------------------------- /doc/source/images/architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/sparksql-for-hbase/HEAD/doc/source/images/architecture.png -------------------------------------------------------------------------------- /scripts/import_data.txt: -------------------------------------------------------------------------------- 1 | # Please modify '/data/store_sales.txt' to the actual location of the store_sales.txt file 2 | # Use absolute path to point to that file 3 | 4 | LOAD DATA LOCAL INPATH '/data/store_sales.txt' INTO TABLE store_sales 5 | -------------------------------------------------------------------------------- /ACKNOWLEDGEMENTS.md: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | 3 | - Credit goes to *Yan Zhou* for his initial design and continuous implementation with Spark release. 4 | - Credit goes to *Bo Meng* and *Xinyun Huang* for their implementation. 5 | - Credit goes to *Huaxin Gao* for her testing of this journey. 6 | - Credit goes to *Rich Hagarty* for his contribution on testing, writing and making video for this journey document. 7 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | This is an open source project, and we appreciate your help! 4 | 5 | We use the GitHub issue tracker to discuss new features and non-trivial bugs. 6 | 7 | In addition to the issue tracker, [#journeys on 8 | Slack](https://dwopen.slack.com) is the best way to get into contact with the 9 | project's maintainers. 10 | 11 | To contribute code, documentation, or tests, please submit a pull request to 12 | the GitHub repository. Generally, we expect two maintainers to review your pull 13 | request before it is approved for merging. For more details, see the 14 | [MAINTAINERS](MAINTAINERS.md) page. 15 | -------------------------------------------------------------------------------- /MAINTAINERS.md: -------------------------------------------------------------------------------- 1 | # Maintainers Guide 2 | 3 | This guide is intended for maintainers - anybody with commit access to one or 4 | more Code Pattern repositories. 5 | 6 | ## Methodology 7 | 8 | This repository does not have a traditional release management cycle, but 9 | should instead be maintained as as a useful, working, and polished reference at 10 | all times. While all work can therefore be focused on the master branch, the 11 | quality of this branch should never be compromised. 12 | 13 | The remainder of this document details how to merge pull requests to the 14 | repositories. 15 | 16 | ## Merge approval 17 | 18 | The project maintainers use LGTM (Looks Good To Me) in comments on the pull 19 | request to indicate acceptance prior to merging. A change requires LGTMs from 20 | two project maintainers. If the code is written by a maintainer, the change 21 | only requires one additional LGTM. 22 | 23 | ## Reviewing Pull Requests 24 | 25 | We recommend reviewing pull requests directly within GitHub. This allows a 26 | public commentary on changes, providing transparency for all users. When 27 | providing feedback be civil, courteous, and kind. Disagreement is fine, so long 28 | as the discourse is carried out politely. If we see a record of uncivil or 29 | abusive comments, we will revoke your commit privileges and invite you to leave 30 | the project. 31 | 32 | During your review, consider the following points: 33 | 34 | ### Does the change have positive impact? 35 | 36 | Some proposed changes may not represent a positive impact to the project. Ask 37 | whether or not the change will make understanding the code easier, or if it 38 | could simply be a personal preference on the part of the author (see 39 | [bikeshedding](https://en.wiktionary.org/wiki/bikeshedding)). 40 | 41 | Pull requests that do not have a clear positive impact should be closed without 42 | merging. 43 | 44 | ### Do the changes make sense? 45 | 46 | If you do not understand what the changes are or what they accomplish, ask the 47 | author for clarification. Ask the author to add comments and/or clarify test 48 | case names to make the intentions clear. 49 | 50 | At times, such clarification will reveal that the author may not be using the 51 | code correctly, or is unaware of features that accommodate their needs. If you 52 | feel this is the case, work up a code sample that would address the pull 53 | request for them, and feel free to close the pull request once they confirm. 54 | 55 | ### Does the change introduce a new feature? 56 | 57 | For any given pull request, ask yourself "is this a new feature?" If so, does 58 | the pull request (or associated issue) contain narrative indicating the need 59 | for the feature? If not, ask them to provide that information. 60 | 61 | Are new unit tests in place that test all new behaviors introduced? If not, do 62 | not merge the feature until they are! Is documentation in place for the new 63 | feature? (See the documentation guidelines). If not do not merge the feature 64 | until it is! Is the feature necessary for general use cases? Try and keep the 65 | scope of any given component narrow. If a proposed feature does not fit that 66 | scope, recommend to the user that they maintain the feature on their own, and 67 | close the request. You may also recommend that they see if the feature gains 68 | traction among other users, and suggest they re-submit when they can show such 69 | support. 70 | -------------------------------------------------------------------------------- /scripts/query_table.txt: -------------------------------------------------------------------------------- 1 | Query 1: 2 | SELECT count(1) FROM store_sales 3 | 4 | Expected result: 5 | +--------+ 6 | |count(1)| 7 | +--------+ 8 | | 100| 9 | +--------+ 10 | 11 | Query 2: 12 | SELECT ss_quantity, ss_wholesale_cost, ss_list_price FROM store_sales WHERE ss_item_sk = 2744 AND ss_ticket_number = 1 13 | 14 | Expected result: 15 | +-----------+-----------------+-------------+ 16 | |ss_quantity|ss_wholesale_cost|ss_list_price| 17 | +-----------+-----------------+-------------+ 18 | | 37| 63.63| 101.17| 19 | +-----------+-----------------+-------------+ 20 | 21 | Query 3: 22 | SELECT ss_sold_date_sk, ss_sold_time_sk, ss_store_sk FROM store_sales WHERE ss_item_sk = 2744 AND ss_ticket_number = 1 23 | 24 | Expected result: 25 | +---------------+---------------+-----------+ 26 | |ss_sold_date_sk|ss_sold_time_sk|ss_store_sk| 27 | +---------------+---------------+-----------+ 28 | | 2451813| 65495| 25| 29 | +---------------+---------------+-----------+ 30 | 31 | Query 4: 32 | SELECT ss_item_sk, count(1) FROM store_sales GROUP BY ss_item_sk 33 | 34 | Expected result: 35 | +----------+--------+ 36 | |ss_item_sk|count(1)| 37 | +----------+--------+ 38 | | 808| 1| 39 | | 5695| 1| 40 | | 20719| 1| 41 | | 21872| 1| 42 | | 4424| 1| 43 | | 1030| 1| 44 | | 27645| 1| 45 | | 12597| 1| 46 | | 10861| 1| 47 | | 26996| 1| 48 | | 9474| 1| 49 | | 6469| 1| 50 | | 17447| 1| 51 | | 4472| 1| 52 | | 26337| 1| 53 | | 5791| 1| 54 | | 14389| 1| 55 | | 9052| 1| 56 | | 11557| 1| 57 | | 9483| 1| 58 | | 24989| 1| 59 | | 7657| 1| 60 | | 10423| 1| 61 | | 10378| 1| 62 | | 8263| 1| 63 | | 13616| 1| 64 | | 21995| 1| 65 | | 17183| 1| 66 | | 8558| 1| 67 | | 10417| 1| 68 | | 347| 1| 69 | | 23272| 1| 70 | | 2524| 1| 71 | | 5186| 1| 72 | | 5476| 1| 73 | | 19748| 1| 74 | | 25084| 1| 75 | | 26391| 1| 76 | | 24974| 1| 77 | | 3163| 1| 78 | | 11869| 1| 79 | | 13092| 1| 80 | | 27149| 1| 81 | | 3304| 1| 82 | | 6685| 1| 83 | | 7227| 1| 84 | | 12617| 1| 85 | | 10930| 1| 86 | | 5602| 1| 87 | | 15079| 1| 88 | | 21315| 1| 89 | | 18189| 1| 90 | | 26116| 1| 91 | | 7937| 1| 92 | | 3537| 1| 93 | | 22174| 1| 94 | | 11635| 1| 95 | | 14761| 1| 96 | | 23251| 1| 97 | | 16833| 1| 98 | | 9463| 1| 99 | | 6991| 1| 100 | | 19123| 1| 101 | | 2578| 1| 102 | | 3318| 1| 103 | | 24025| 1| 104 | | 8129| 1| 105 | | 2529| 1| 106 | | 1592| 1| 107 | | 14371| 1| 108 | | 6851| 1| 109 | | 4878| 1| 110 | | 19693| 1| 111 | | 2744| 1| 112 | | 4540| 1| 113 | | 23918| 1| 114 | | 13942| 1| 115 | | 14664| 1| 116 | | 24364| 1| 117 | | 3109| 1| 118 | | 21862| 1| 119 | | 14893| 1| 120 | | 15139| 1| 121 | | 10499| 1| 122 | | 317| 1| 123 | | 13335| 1| 124 | | 765| 1| 125 | | 16689| 1| 126 | | 5977| 1| 127 | | 18752| 1| 128 | | 22890| 1| 129 | | 21549| 1| 130 | | 186| 1| 131 | | 22203| 1| 132 | | 11268| 1| 133 | | 22526| 1| 134 | | 1857| 1| 135 | | 4214| 1| 136 | | 24682| 1| 137 | | 3836| 1| 138 | +----------+--------+ 139 | 140 | Query 5: 141 | SELECT ss_wholesale_cost, ss_item_sk FROM store_sales WHERE ss_quantity > 80 142 | 143 | Expected result: 144 | +-----------------+----------+ 145 | |ss_wholesale_cost|ss_item_sk| 146 | +-----------------+----------+ 147 | | 27.68| 1592| 148 | | 91.8| 2529| 149 | | 56.14| 3109| 150 | | 69.53| 3163| 151 | | 85.0| 4878| 152 | | 25.08| 5977| 153 | | 81.63| 9483| 154 | | 64.67| 10861| 155 | | 27.95| 12597| 156 | | 21.29| 13335| 157 | | 64.43| 13942| 158 | | 14.11| 14761| 159 | | 35.87| 15139| 160 | | 31.78| 16689| 161 | | 52.41| 17447| 162 | | 93.48| 19748| 163 | | 98.02| 20719| 164 | | 62.67| 22203| 165 | | 38.23| 23251| 166 | | 80.52| 23918| 167 | | 74.15| 24364| 168 | | 4.45| 26337| 169 | | 41.08| 27149| 170 | +-----------------+----------+ 171 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Using Spark SQL to access NOSQL HBase Tables 2 | 3 | Apache HBase is an open source, NOSQL distributed database which runs on top of the Hadoop Distributed File System (HDFS), and is well-suited for faster read/write operations on large datasets with high throughput and low input/output latency. But, unlike relational and traditional databases, HBase lacks support for SQL scripting, data types, etc., and requires the Java API to achieve the equivalent functionality. 4 | 5 | This journey is intended to provide application developers familiar with SQL, the ability to access HBase data tables using the same SQL commands. You will quickly learn how to create and query the data tables by using Apache Spark SQL and the HSpark connector package. This allows you to take advantage of the significant performance gains from using HBase without having to learn the Java APIs required to traditionally access the HBase data tables. 6 | 7 | When you have completed this journey, you will understand how to: 8 | 9 | - Install and configure [Apache Spark](https://spark.apache.org/) and [HSpark](https://github.com/bomeng/Heracles) connector. 10 | - Learn to create metadata for tables in [Apache HBase](https://hbase.apache.org/). 11 | - Write Spark SQL queries to retrieve HBase data for analysis. 12 | 13 | ![Architecture diagram](doc/source/images/architecture.png) 14 | 15 | ## Flow 16 | 17 | 1. Set up the environment (Apache Spark, Apache HBase, and HSpark). 18 | 2. Create the tables using HSpark. 19 | 3. Load the data into the tables. 20 | 4. Query the data using HSpark Shell. 21 | 22 | ## Included Components: 23 | - [Apache Spark](https://spark.apache.org/): An open-source, fast and general-purpose cluster computing system. 24 | - [Apache HBase](https://hbase.apache.org/): A distribute key/value data store built to run on top of HDFS. 25 | - [HSpark](https://github.com/bomeng/Heracles): Provides access to HBase using SparkSQL. 26 | 27 | There are also some core tools you will need to complete this journey. If you do not already have them installed, please refer to the corresponding documents for installation instructions. Ensure that the proper system environment variables are correctly set (such as `PATH`, `JAVA_HOME` and `MVN_HOME`). 28 | 29 | - [Apache Maven 3.5.0](https://maven.apache.org/): A build automation tool primarily used for Java projects. 30 | - [Java JDK 1.8.0_144](https://www.oracle.com/technetwork/java/javase/downloads/index.html): A software development environment used for developing Java applications. 31 | 32 | # Watch the Video 33 | [![](https://img.youtube.com/vi/E1GPJMn0qF0/0.jpg)](https://www.youtube.com/watch?v=E1GPJMn0qF0) 34 | 35 | # Steps 36 | 37 | Perform the following steps: 38 | 39 | 1. [Install Apache Spark](#1-install-apache-spark) 40 | 2. [Install and run Apache HBase](#2-install-and-run-apache-hbase) 41 | 3. [Download and build HSpark](#3-download-and-build-hspark) 42 | 4. [Start the HSpark shell](#4-start-the-hspark-shell) 43 | 5. [Use HSpark to access TPC-DS data](#5-use-hspark-to-access-tpc-ds-data) 44 | 45 | ## 1. Install Apache Spark 46 | 47 | HSpark relies on Apache Spark, thus you need to install Apache Spark first. Download Apache Spark 2.2.0 from the [downloads page](https://spark.apache.org/downloads.html). 48 | 49 | You may also download the source codes from [Apache Spark GiHub](https://github.com/apache/spark) and build it using the 2.2 branch. 50 | 51 | To set-up and configure Apache Spark, please refer to the [on-line users guide](https://spark.apache.org/docs/latest/). 52 | 53 | In order to make HSpark work properly, you may need to set the `SPARK_HOME` environment variable to point to your installation directory: 54 | 55 | ```sh 56 | $ export SPARK_HOME= 57 | ``` 58 | 59 | ## 2. Install and run Apache HBase 60 | 61 | Currently, HSpark works with Apache HBase 1.2.4. Go to the [downloads page](https://archive.apache.org/dist/hbase/1.2.4/) to install it. 62 | 63 | HBase can be installed to run in 3 different modes – standalone, pseudo-distributed, and fully distributed. 64 | 65 | For our simple demonstration of running HSpark in a single machine, we recommend you run it in pseudo-distributed mode. This mode runs HBase completely on a single host, but all daemons run as a separate process. 66 | 67 | For reference, refer to this [guide](https://hbase.apache.org/book.html#quickstart) to review how to install and run in each of the modes. 68 | 69 | Also properly set up the environment variable `HBASE_HOME` and add it to `PATH`. 70 | 71 | ```sh 72 | $ cd $HBASE_HOME 73 | $ ./bin/start-hbase.sh 74 | ``` 75 | To test that HBase is up and running, access the HBase Web UI at [http://localhost:16010](http://localhost:16010) 76 | 77 | ## 3. Download and build HSpark 78 | 79 | Use git to clone `version 2.2.0` of the source code from github and set up an environment property `HSPARK_HOME`: 80 | 81 | ```sh 82 | $ git clone https://github.com/bomeng/Heracles.git 83 | $ export HSPARK_HOME= 84 | ``` 85 | 86 | Configure the proper values in `hspark.properties` found in the `HSpark/conf` folder. Depending on your HBase running mode, you can leave the values as is, or modify them as specified in the comments found in the file. 87 | 88 | Go to the root of the source tree and use Apache Maven to build the project: 89 | 90 | ```sh 91 | $ cd $HSPARK_HOME 92 | $ mvn -DskipTests clean install 93 | ``` 94 | 95 | In order to use the HSpark SQL shell, you will need to add the built HSpark jar to the HBASE classpath: 96 | 97 | ```sh 98 | $ export HBASE_CLASSPATH=$HSPARK_HOME/target/hspark-2.2.0.jar 99 | ``` 100 | 101 | ## 4. Start the HSpark shell 102 | 103 | HSpark shell is a convenient tool for the developers or users to try HSpark quickly. It supports the basic SQL commands to create tables, import data and perform queries. After we have installed Spark, HBase and HSpark, now we can start the HSpark shell: 104 | 105 | ```sh 106 | $ cd $HSPARK_HOME 107 | $ ./bin/hbase-sql 108 | ``` 109 | 110 | ## 5. Use HSpark to access TPC-DS data 111 | 112 | [The TPC Benchmark™DS (TPC-DS)](http://www.tpc.org/tpcds/) is a decision support benchmark that models several generally applicable aspects of a decision support system, including queries and data maintenance. TPC-DS is the de-facto industry standard benchmark for measuring the performance of decision support solutions including, but not limited to, Big Data systems. 113 | 114 | In order to demonstrate HSpark’s capability, we will use some of the TPC-DS schema to create the tables in HBase and then import the sample data into those tables. We can then use HSpark to do various queries against these tables. 115 | 116 | ### Schemas 117 | 118 | We will take some tables from the TPC-DS definition. Here is the schema (the primary keys in each table are underlined): 119 | 120 | [![N|Solid](doc/source/images/schema.png)](doc/source/images/schema.png) 121 | 122 | ### Create the tables using script in the HSpark shell 123 | 124 | Currently, HSpark supports several data types that are commonly used. For the TPC-DS schema, the data types can be mapped as the following: 125 | 126 | | TPC-DS data type | HSpark data type | 127 | | ------ | ------ | 128 | | Identifier | Integer | 129 | | Integer | Integer | 130 | | Decimal(d, f) | Float or Double | 131 | | Char(N) or Varchar(N) | String | 132 | | Date | Long | 133 | 134 | Please find the table creation commands in the [scripts](scripts) folder. There you will find 5 commands that you need to cut and paste into the HSpark Shell. 135 | 136 | ### Import data into the tables using script in the HSpark shell 137 | 138 | HSpark supports bulk-load of data into the tables. The data can be defined in CSV files. By using the TPC-DS tool, you can generate the data at your preferred size. 139 | 140 | HSpark can import CSV data files that you generate by using the TPC-DS tool. A sample CSV file(store_sales.txt) can be found in the [data](data) folder. 141 | 142 | To import this sample CSV data file into the `store_sales` table, modify and enter the following command: 143 | 144 | ```sh 145 | LOAD DATA LOCAL INPATH '/data/store_sales.txt' INTO TABLE store_sales 146 | ``` 147 | *Note:* This command may fail with a `Mkdirs failed to create` error. See [Troubleshooting](#troubleshooting) section below. 148 | 149 | ### Query the tables using script in the HSpark shell 150 | 151 | After importing the data into the tables, we can now query the tables using regular SQL queries; for example, 152 | 153 | ```sh 154 | SELECT count(1) FROM store_sales 155 | ``` 156 | 157 | More query examples can be found in the [scripts](scripts) folder, along with expected output from each of the queries. 158 | 159 | ### Using HSpark programmatically 160 | 161 | HSpark can also be used to programmatically create tables, import data and run queries. Visit the HSpack source code repository at [https://github.com/bomeng/Heracles](https://github.com/bomeng/Heracles/tree/master/src/test) for more details. 162 | 163 | # Troubleshooting 164 | 165 | * Error: `java.io.IOException: Mkdirs failed to create /user//hbase-staging` 166 | 167 | If you see this error while running the LOAD command, it means you need to create a temporary folder locally to allow hbase to store intermediate result. 168 | 169 | > Solution: Create the *hbase-staging* directory that is required by hbase (using `mkdir` and `chmod` to create the directory manually). 170 | 171 | * Error: `java.net.ConnectException: Connection refused` 172 | 173 | If you see this error while running the command, it usually means HSpark cannot connect to HBase, either it is due to connection configuration issue, or HBase is not up and running. 174 | 175 | > Solution: Make sure HBase is properly configured and is running. You can also use `jps` to check if it is running. 176 | 177 | * Error: `org.apache.spark.sql.catalyst.parser.ParseException` 178 | 179 | If you see this error while running any command, it means your command syntax is not correct. 180 | 181 | > Solution: Make sure your command is just one single line and has the correct syntax, especially for the single quote, space, etc. Although some example scripts look like multi-line commands, they are actually just single-line commands. 182 | 183 | # Links 184 | * [Demo on Youtube](https://www.youtube.com/watch?v=E1GPJMn0qF0): Watch the video. 185 | * [Performance](https://databricks.com/blog/2014/11/05/spark-officially-sets-a-new-record-in-large-scale-sorting.html): Get more information about Spark performance. 186 | * [HBase performance](https://blog.cloudera.com/blog/2016/06/new-study-evaluating-apache-hbase-performance-on-modern-storage-media/): Learn more about HBase performance. 187 | * [SparkPackages: HSpark](https://spark-packages.org/package/bomeng/HSpark): Learn more about the high-performance HBase Spark SQL engine. 188 | * [BigSQL blog](https://developer.ibm.com/hadoop/2017/07/13/announcing-bigsql-5-0/): Read “Announcing Big SQL 5.0” for more information. 189 | 190 | # Learn more 191 | * **Data Analytics Code Patterns**: Enjoyed this Code Pattern? Check out our other [Data Analytics Code Patterns](https://developer.ibm.com/technologies/data-science/) 192 | * **AI and Data Code Pattern Playlist**: Bookmark our [playlist](https://www.youtube.com/playlist?list=PLzUbsvIyrNfknNewObx5N7uGZ5FKH0Fde) with all of our Code Pattern videos 193 | * **Data Science Experience**: Master the art of data science with IBM's [Data Science Experience](https://www.ibm.com/cloud/watson-studio) 194 | * **Spark on IBM Cloud**: Need a Spark cluster? Create up to 30 Spark executors on IBM Cloud with our [Spark service](https://cloud.ibm.com/catalog/services/apache-spark) 195 | 196 | # License 197 | This code pattern is licensed under the Apache Software License, Version 2. Separate third party code objects invoked within this code pattern are licensed by their respective providers pursuant to their own separate licenses. Contributions are subject to the [Developer Certificate of Origin, Version 1.1 (DCO)](https://developercertificate.org/) and the [Apache Software License, Version 2](https://www.apache.org/licenses/LICENSE-2.0.txt). 198 | 199 | [Apache Software License (ASL) FAQ](https://www.apache.org/foundation/license-faq.html#WhatDoesItMEAN) 200 | -------------------------------------------------------------------------------- /data/store_sales.txt: -------------------------------------------------------------------------------- 1 | 2451813,65495,24989,225006,591617,3428,15839,25,31,1,79,11.41,18.71,2.80,99.54,221.20,901.39,1478.09,6.08,99.54,121.66,127.74,-779.73 2 | 2451813,65495,2744,225006,591617,3428,15839,25,354,1,37,63.63,101.17,41.47,46.03,1534.39,2354.31,3743.29,59.53,46.03,1488.36,1547.89,-865.95 3 | 2451813,65495,23918,225006,591617,3428,15839,25,337,1,99,80.52,137.68,83.98,0.00,8314.02,7971.48,13630.32,0.00,0.00,8314.02,8314.02,342.54 4 | 2451813,65495,4472,225006,591617,3428,15839,25,300,1,14,57.37,76.30,6.10,0.00,85.40,803.18,1068.20,0.00,0.00,85.40,85.40,-717.78 5 | 2451813,65495,5977,225006,591617,3428,15839,25,51,1,100,25.08,36.86,0.73,0.00,73.00,2508.00,3686.00,6.57,0.00,73.00,79.57,-2435.00 6 | 2451813,65495,19748,225006,591617,3428,15839,25,253,1,91,93.48,108.43,93.24,0.00,8484.84,8506.68,9867.13,254.54,0.00,8484.84,8739.38,-21.84 7 | 2451813,65495,24025,225006,591617,3428,15839,25,355,1,5,10.68,15.91,6.68,0.00,33.40,53.40,79.55,2.33,0.00,33.40,35.73,-20.00 8 | 2451813,65495,8558,225006,591617,3428,15839,25,142,1,72,84.72,111.83,61.50,0.00,4428.00,6099.84,8051.76,177.12,0.00,4428.00,4605.12,-1671.84 9 | 2451813,65495,12617,225006,591617,3428,15839,25,71,1,14,11.54,11.77,0.00,0.00,0.00,161.56,164.78,0.00,0.00,0.00,0.00,-161.56 10 | 2451813,65495,8129,225006,591617,3428,15839,25,84,1,58,4.57,5.34,3.52,0.00,204.16,265.06,309.72,0.00,0.00,204.16,204.16,-60.90 11 | 2451813,65495,7657,225006,591617,3428,15839,25,37,1,44,31.07,54.99,24.19,0.00,1064.36,1367.08,2419.56,85.14,0.00,1064.36,1149.50,-302.72 12 | 2451813,65495,17447,225006,591617,3428,15839,25,142,1,88,52.41,63.94,49.23,0.00,4332.24,4612.08,5626.72,259.93,0.00,4332.24,4592.17,-279.84 13 | 2451813,65495,6851,225006,591617,3428,15839,25,62,1,50,67.71,126.61,87.36,0.00,4368.00,3385.50,6330.50,349.44,0.00,4368.00,4717.44,982.50 14 | 2451813,65495,347,225006,591617,3428,15839,25,124,1,65,27.16,52.14,41.19,0.00,2677.35,1765.40,3389.10,214.18,0.00,2677.35,2891.53,911.95 15 | 2451524,75316,3836,194284,1712478,4672,25266,20,12,2,65,93.86,158.62,34.89,0.00,2267.85,6100.90,10310.30,45.35,0.00,2267.85,2313.20,-3833.05 16 | 2451524,75316,15139,194284,1712478,4672,25266,20,271,2,93,35.87,49.14,15.23,0.00,1416.39,3335.91,4570.02,113.31,0.00,1416.39,1529.70,-1919.52 17 | 2451524,75316,26996,194284,1712478,4672,25266,20,288,2,30,2.27,3.83,1.11,0.00,33.30,68.10,114.90,0.00,0.00,33.30,33.30,-34.80 18 | 2451524,75316,4540,194284,1712478,4672,25266,20,180,2,58,53.09,58.39,7.59,0.00,440.22,3079.22,3386.62,0.00,0.00,440.22,440.22,-2639.00 19 | ,75316,11869,,,4672,,20,,2,,17.12,19.85,,,,,,19.07,,,495.84, 20 | 2451524,75316,24974,194284,1712478,4672,25266,20,319,2,79,88.02,128.50,69.39,4549.90,5481.81,6953.58,10151.50,83.87,4549.90,931.91,1015.78,-6021.67 21 | 2451524,75316,5476,194284,1712478,4672,25266,20,206,2,25,74.26,89.11,35.64,0.00,891.00,1856.50,2227.75,8.91,0.00,891.00,899.91,-965.50 22 | 2451524,75316,2524,194284,1712478,4672,25266,20,17,2,78,65.71,88.70,23.06,341.74,1798.68,5125.38,6918.60,131.12,341.74,1456.94,1588.06,-3668.44 23 | 2451524,75316,13942,194284,1712478,4672,25266,20,337,2,88,64.43,79.89,41.54,0.00,3655.52,5669.84,7030.32,146.22,0.00,3655.52,3801.74,-2014.32 24 | 2451524,75316,22526,194284,1712478,4672,25266,20,207,2,49,6.55,7.86,7.46,0.00,365.54,320.95,385.14,0.00,0.00,365.54,365.54,44.59 25 | 2451524,75316,25084,194284,1712478,4672,25266,20,33,2,4,13.46,15.34,12.57,0.00,50.28,53.84,61.36,4.02,0.00,50.28,54.30,-3.56 26 | 2451524,75316,21862,194284,1712478,4672,25266,20,207,2,74,16.55,17.21,4.47,0.00,330.78,1224.70,1273.54,0.00,0.00,330.78,330.78,-893.92 27 | 2451524,75316,10423,194284,1712478,4672,25266,20,147,2,71,36.01,64.09,3.20,0.00,227.20,2556.71,4550.39,4.54,0.00,227.20,231.74,-2329.51 28 | 2451524,75316,808,194284,1712478,4672,25266,20,249,2,36,61.23,93.06,11.16,0.00,401.76,2204.28,3350.16,28.12,0.00,401.76,429.88,-1802.52 29 | 2451524,75316,5186,194284,1712478,4672,25266,20,88,2,62,77.97,85.76,79.75,0.00,4944.50,4834.14,5317.12,0.00,0.00,4944.50,4944.50,110.36 30 | 2452638,50412,3109,47,586372,697,42622,32,183,3,82,56.14,111.15,46.68,0.00,3827.76,4603.48,9114.30,306.22,0.00,3827.76,4133.98,-775.72 31 | 2452638,50412,20719,47,586372,697,42622,32,99,3,96,98.02,136.24,104.90,0.00,10070.40,9409.92,13079.04,100.70,0.00,10070.40,10171.10,660.48 32 | ,,11268,,,,42622,32,37,3,,,130.66,,,3104.46,,3527.82,124.17,,,, 33 | 2452638,50412,13092,47,586372,697,42622,32,100,3,42,97.03,178.53,7.14,0.00,299.88,4075.26,7498.26,17.99,0.00,299.88,317.87,-3775.38 34 | 2452638,50412,6685,47,586372,697,42622,32,331,3,64,74.69,120.25,2.40,0.00,153.60,4780.16,7696.00,3.07,0.00,153.60,156.67,-4626.56 35 | 2452638,50412,14664,47,586372,697,42622,32,209,3,17,72.38,111.46,75.79,0.00,1288.43,1230.46,1894.82,38.65,0.00,1288.43,1327.08,57.97 36 | 2452638,50412,12597,47,586372,697,42622,32,131,3,88,27.95,38.57,26.99,403.77,2375.12,2459.60,3394.16,0.00,403.77,1971.35,1971.35,-488.25 37 | 2452638,50412,9474,47,586372,697,42622,32,301,3,4,95.75,146.49,43.94,0.00,175.76,383.00,585.96,5.27,0.00,175.76,181.03,-207.24 38 | 2452638,50412,3318,47,586372,697,42622,32,222,3,79,44.66,83.06,17.44,1115.98,1377.76,3528.14,6561.74,5.23,1115.98,261.78,267.01,-3266.36 39 | 2452638,50412,186,47,586372,697,42622,32,196,3,56,4.31,6.76,0.06,3.22,3.36,241.36,378.56,0.01,3.22,0.14,0.15,-241.22 40 | 2452638,50412,8263,47,586372,697,42622,32,335,3,27,37.04,58.89,55.35,0.00,1494.45,1000.08,1590.03,29.88,0.00,1494.45,1524.33,494.37 41 | 2452638,50412,22890,47,586372,697,42622,32,62,3,4,75.67,130.15,35.14,0.00,140.56,302.68,520.60,9.83,0.00,140.56,150.39,-162.12 42 | 2452638,50412,18189,47,586372,697,42622,32,60,3,53,23.04,44.00,26.40,0.00,1399.20,1221.12,2332.00,13.99,0.00,1399.20,1413.19,178.08 43 | 2452638,50412,4878,47,586372,697,42622,32,180,3,98,85.00,132.60,90.16,4506.19,8835.68,8330.00,12994.80,0.00,4506.19,4329.49,4329.49,-4000.51 44 | 2451438,38195,1030,118814,874786,1511,130083,43,37,4,43,54.34,107.59,87.14,0.00,3747.02,2336.62,4626.37,299.76,0.00,3747.02,4046.78,1410.40 45 | 2451438,38195,11557,118814,874786,1511,130083,43,269,4,23,2.91,3.57,3.53,32.47,81.19,66.93,82.11,0.97,32.47,48.72,49.69,-18.21 46 | 2451438,38195,18752,118814,874786,1511,130083,43,201,4,56,64.68,78.90,24.45,0.00,1369.20,3622.08,4418.40,0.00,0.00,1369.20,1369.20,-2252.88 47 | 2451438,38195,13616,118814,874786,1511,130083,43,154,4,21,40.39,40.39,12.11,0.00,254.31,848.19,848.19,22.88,0.00,254.31,277.19,-593.88 48 | 2451438,38195,24682,118814,874786,1511,130083,43,169,4,41,67.18,78.60,5.50,0.00,225.50,2754.38,3222.60,13.53,0.00,225.50,239.03,-2528.88 49 | 2451438,38195,3304,118814,874786,1511,130083,43,142,4,27,26.21,44.81,19.26,0.00,520.02,707.67,1209.87,46.80,0.00,520.02,566.82,-187.65 50 | 2451438,38195,10861,118814,874786,1511,130083,43,191,4,86,64.67,123.51,55.57,0.00,4779.02,5561.62,10621.86,47.79,0.00,4779.02,4826.81,-782.60 51 | 2451438,38195,15079,118814,874786,1511,130083,43,340,4,17,54.26,105.80,9.52,116.52,161.84,922.42,1798.60,0.00,116.52,45.32,45.32,-877.10 52 | 2451438,38195,2578,118814,874786,1511,130083,43,295,4,74,81.81,163.62,45.81,0.00,3389.94,6053.94,12107.88,271.19,0.00,3389.94,3661.13,-2664.00 53 | 2451438,38195,9052,118814,874786,1511,130083,43,32,4,23,53.28,77.78,1.55,21.03,35.65,1225.44,1788.94,1.16,21.03,14.62,15.78,-1210.82 54 | 2451465,53976,22174,119246,963544,5042,99940,26,35,5,60,69.54,112.65,57.45,0.00,3447.00,4172.40,6759.00,34.47,0.00,3447.00,3481.47,-725.40 55 | 2451465,53976,21872,119246,963544,5042,99940,26,321,5,52,16.33,32.33,31.68,0.00,1647.36,849.16,1681.16,115.31,0.00,1647.36,1762.67,798.20 56 | 2451465,53976,24364,119246,963544,5042,99940,26,52,5,83,74.15,89.72,63.70,0.00,5287.10,6154.45,7446.76,422.96,0.00,5287.10,5710.06,-867.35 57 | 2451465,53976,10930,119246,963544,5042,99940,26,294,5,15,21.21,33.93,30.53,0.00,457.95,318.15,508.95,22.89,0.00,457.95,480.84,139.80 58 | 2451465,53976,5791,119246,963544,5042,99940,26,67,5,71,22.10,37.57,28.17,0.00,2000.07,1569.10,2667.47,180.00,0.00,2000.07,2180.07,430.97 59 | 2451465,53976,4424,119246,963544,5042,99940,26,55,5,36,7.93,12.92,7.36,0.00,264.96,285.48,465.12,0.00,0.00,264.96,264.96,-20.52 60 | 2451465,53976,26116,119246,963544,5042,99940,26,10,5,66,71.06,136.43,45.02,0.00,2971.32,4689.96,9004.38,59.42,0.00,2971.32,3030.74,-1718.64 61 | 2451465,53976,4214,,963544,5042,99940,26,5,5,66,21.01,28.57,5.99,0.00,395.34,1386.66,1885.62,7.90,0.00,395.34,403.24,-991.32 62 | ,53976,5602,,963544,,,26,318,5,50,30.69,59.84,,,,1534.50,,0.00,,1735.00,,200.50 63 | 2451465,53976,1592,119246,963544,5042,99940,26,45,5,91,27.68,53.69,0.53,0.00,48.23,2518.88,4885.79,3.85,0.00,48.23,52.08,-2470.65 64 | 2451465,53976,14893,119246,963544,5042,99940,26,190,5,76,89.78,103.24,50.58,0.00,3844.08,6823.28,7846.24,153.76,0.00,3844.08,3997.84,-2979.20 65 | 2451465,53976,14389,119246,963544,5042,99940,26,215,5,64,87.90,95.81,66.10,0.00,4230.40,5625.60,6131.84,0.00,0.00,4230.40,4230.40,-1395.20 66 | 2451465,53976,23272,119246,963544,5042,99940,26,104,5,60,41.72,52.98,32.31,0.00,1938.60,2503.20,3178.80,0.00,0.00,1938.60,1938.60,-564.60 67 | ,53976,6991,119246,,,99940,26,,5,,,77.52,11.62,0.00,732.06,,4883.76,43.92,0.00,,, 68 | 2451465,53976,10378,119246,963544,5042,99940,26,156,5,50,30.96,56.34,45.07,0.00,2253.50,1548.00,2817.00,22.53,0.00,2253.50,2276.03,705.50 69 | ,,17183,75029,,2092,,,48,6,,,,,,449.88,,,,,,, 70 | 2452109,36794,3537,75029,506184,2092,45800,34,212,6,31,49.78,77.15,69.43,0.00,2152.33,1543.18,2391.65,0.00,0.00,2152.33,2152.33,609.15 71 | 2452109,36794,10499,75029,506184,2092,45800,34,18,6,62,85.07,159.08,76.35,0.00,4733.70,5274.34,9862.96,189.34,0.00,4733.70,4923.04,-540.64 72 | 2452109,36794,16833,75029,506184,2092,45800,34,16,6,1,71.10,89.58,61.81,0.00,61.81,71.10,89.58,3.70,0.00,61.81,65.51,-9.29 73 | 2452109,36794,7227,75029,506184,2092,45800,34,329,6,61,48.18,60.70,18.81,126.21,1147.41,2938.98,3702.70,71.48,126.21,1021.20,1092.68,-1917.78 74 | 2452109,36794,19123,75029,506184,2092,45800,34,208,6,42,64.46,70.26,32.31,0.00,1357.02,2707.32,2950.92,27.14,0.00,1357.02,1384.16,-1350.30 75 | 2452109,36794,27149,75029,506184,2092,45800,34,73,6,100,41.08,42.31,38.50,0.00,3850.00,4108.00,4231.00,346.50,0.00,3850.00,4196.50,-258.00 76 | 2452109,36794,7937,75029,506184,2092,45800,34,222,6,64,86.35,152.83,122.26,6650.94,7824.64,5526.40,9781.12,35.21,6650.94,1173.70,1208.91,-4352.70 77 | 2452109,36794,22203,75029,506184,2092,45800,34,46,6,94,62.67,99.64,97.64,0.00,9178.16,5890.98,9366.16,91.78,0.00,9178.16,9269.94,3287.18 78 | 2452109,36794,19693,75029,506184,2092,45800,34,33,6,72,55.49,93.77,55.32,0.00,3983.04,3995.28,6751.44,199.15,0.00,3983.04,4182.19,-12.24 79 | 2452109,36794,26337,75029,506184,2092,45800,34,125,6,100,4.45,7.87,7.24,0.00,724.00,445.00,787.00,57.92,0.00,724.00,781.92,279.00 80 | 2452260,46712,317,147954,890396,791,97633,19,311,7,51,84.65,124.43,49.77,0.00,2538.27,4317.15,6345.93,76.14,0.00,2538.27,2614.41,-1778.88 81 | 2452260,46712,6469,147954,890396,791,97633,19,185,7,9,56.13,59.49,30.93,0.00,278.37,505.17,535.41,22.26,0.00,278.37,300.63,-226.80 82 | 2452260,,21549,147954,890396,791,,,,7,4,,,,,278.60,203.68,366.60,22.28,,278.60,300.88, 83 | 2452260,46712,11635,147954,,,,,345,7,,,72.02,,,,,,,,4990.30,,1141.70 84 | 2452260,46712,23251,147954,890396,791,97633,19,328,7,88,38.23,72.63,39.22,0.00,3451.36,3364.24,6391.44,138.05,0.00,3451.36,3589.41,87.12 85 | 2452260,46712,26391,147954,890396,791,97633,19,233,7,52,63.80,81.02,22.68,0.00,1179.36,3317.60,4213.04,23.58,0.00,1179.36,1202.94,-2138.24 86 | 2452260,46712,765,147954,890396,791,97633,19,237,7,69,99.85,113.82,110.40,0.00,7617.60,6889.65,7853.58,0.00,0.00,7617.60,7617.60,727.95 87 | 2452260,46712,21315,147954,890396,791,97633,19,335,7,54,42.82,56.09,21.31,0.00,1150.74,2312.28,3028.86,92.05,0.00,1150.74,1242.79,-1161.54 88 | 2452260,46712,9463,147954,890396,791,97633,19,125,7,12,47.60,75.20,65.42,0.00,785.04,571.20,902.40,47.10,0.00,785.04,832.14,213.84 89 | 2452260,46712,27645,147954,890396,791,97633,19,307,7,73,12.17,14.23,11.24,623.59,820.52,888.41,1038.79,5.90,623.59,196.93,202.83,-691.48 90 | 2452260,46712,1857,147954,890396,791,97633,19,75,7,69,34.19,58.46,50.86,0.00,3509.34,2359.11,4033.74,210.56,0.00,3509.34,3719.90,1150.23 91 | 2452260,46712,3163,147954,890396,791,97633,19,22,7,82,69.53,87.60,34.16,0.00,2801.12,5701.46,7183.20,0.00,0.00,2801.12,2801.12,-2900.34 92 | 2452179,52209,9483,202944,578318,6045,121019,19,194,8,90,81.63,151.83,113.87,9428.43,10248.30,7346.70,13664.70,40.99,9428.43,819.87,860.86,-6526.83 93 | 2452179,52209,16689,202944,578318,6045,121019,19,161,8,87,31.78,63.24,16.44,0.00,1430.28,2764.86,5501.88,57.21,0.00,1430.28,1487.49,-1334.58 94 | 2452179,52209,14371,202944,578318,6045,121019,19,288,8,31,15.64,26.43,13.21,0.00,409.51,484.84,819.33,4.09,0.00,409.51,413.60,-75.33 95 | 2452179,52209,13335,202944,578318,6045,121019,19,121,8,95,21.29,33.85,20.64,0.00,1960.80,2022.55,3215.75,98.04,0.00,1960.80,2058.84,-61.75 96 | 2452179,52209,21995,202944,578318,6045,121019,19,214,8,7,18.65,27.97,20.41,0.00,142.87,130.55,195.79,1.42,0.00,142.87,144.29,12.32 97 | 2452179,52209,10417,202944,578318,6045,121019,19,127,8,54,36.99,47.71,27.67,0.00,1494.18,1997.46,2576.34,89.65,0.00,1494.18,1583.83,-503.28 98 | 2452179,52209,2529,202944,578318,6045,121019,19,249,8,95,91.80,93.63,75.84,6700.46,7204.80,8721.00,8894.85,5.04,6700.46,504.34,509.38,-8216.66 99 | 2452179,52209,14761,202944,578318,6045,121019,19,353,8,83,14.11,27.37,3.28,0.00,272.24,1171.13,2271.71,13.61,0.00,272.24,285.85,-898.89 100 | 2452179,52209,5695,202944,578318,6045,121019,19,320,8,20,18.95,33.92,31.88,0.00,637.60,379.00,678.40,51.00,0.00,637.60,688.60,258.60 101 | -------------------------------------------------------------------------------- /scripts/create_table.txt: -------------------------------------------------------------------------------- 1 | # Step 1: create table item 2 | # 3 | # CREATE TABLE item ( 4 | # i_item_sk INTEGER, 5 | # i_item_id STRING, 6 | # i_rec_start_date LONG, 7 | # i_rec_end_date LONG, 8 | # i_item_desc STRING, 9 | # i_current_price FLOAT, 10 | # i_wholesale_cost FLOAT, 11 | # i_brand_id INTEGER, 12 | # i_brand STRING, 13 | # i_class_id INTEGER, 14 | # i_class STRING, 15 | # i_category_id INTEGER, 16 | # i_category STRING, 17 | # i_manufact_id INTEGER, 18 | # i_manufact STRING, 19 | # i_size STRING, 20 | # i_formulation STRING, 21 | # i_color STRING, 22 | # i_units STRING, 23 | # i_container STRING, 24 | # i_manager_id INTEGER, 25 | # i_product_name STRING) 26 | # TBLPROPERTIES( 27 | # 'hbaseTableName'='item_htable', 28 | # 'keyCols'='i_item_sk', 29 | # 'nonKeyCols'='i_item_id,f,i_item_id; i_rec_start_date,f,i_rec_start_date; i_rec_end_date,f,i_rec_end_date; 30 | # i_item_desc,f,i_item_desc; i_current_price,f,i_current_price; i_wholesale_cost,f,i_wholesale_cost; 31 | # i_brand_id,f,i_brand_id; i_brand,f,i_brand; i_class_id,f,i_class_id; i_class,f,i_class; 32 | # i_category_id,f,i_category_id; i_category,f,i_category; i_manufact_id,f,i_manufact_id; 33 | # i_manufact,f,i_manufact; i_size,f,i_size; 34 | # i_formulation,f,i_formulation;i_color,f,i_color; i_units,f,i_units; i_container,f,i_counter; 35 | # i_manager_id,f,i_manager_id; i_product_name,f,i_product_name') 36 | # 37 | # To create this table, cut and paste the following one-line command: 38 | # 39 | CREATE TABLE item (i_item_sk INTEGER, i_item_id STRING, i_rec_start_date LONG, i_rec_end_date LONG, i_item_desc STRING, i_current_price FLOAT, i_wholesale_cost FLOAT, i_brand_id INTEGER, i_brand STRING, i_class_id INTEGER, i_class STRING, i_category_id INTEGER, i_category STRING, i_manufact_id INTEGER, i_manufact STRING, i_size STRING, i_formulation STRING, i_color STRING, i_units STRING, i_container STRING, i_manager_id INTEGER, i_product_name STRING) TBLPROPERTIES('hbaseTableName'='item_htable', 'keyCols'='i_item_sk', 'nonKeyCols'='i_item_id,f,i_item_id;i_rec_start_date,f,i_rec_start_date;i_rec_end_date,f,i_rec_end_date;i_item_desc,f,i_item_desc;i_current_price,f,i_current_price;i_wholesale_cost,f,i_wholesale_cost;i_brand_id,f,i_brand_id;i_brand,f,i_brand;i_class_id,f,i_class_id;i_class,f,i_class;i_category_id,f,i_category_id;i_category,f,i_category;i_manufact_id,f,i_manufact_id;i_manufact,f,i_manufact;i_size,f,i_size;i_formulation,f,i_formulation;i_color,f,i_color;i_units,f,i_units;i_container,f,i_counter;i_manager_id,f,i_manager_id;i_product_name,f,i_product_name') 40 | 41 | 42 | 43 | # Step 2: create table store_sales 44 | # 45 | # CREATE TABLE store_sales ( 46 | # ss_sold_date_sk INTEGER, 47 | # ss_sold_time_sk INTEGER, 48 | # ss_item_sk INTEGER, 49 | # ss_customer_sk INTEGER, 50 | # ss_cdemo_sk INTEGER, 51 | # ss_hdemo_sk INTEGER, 52 | # ss_addr_sk INTEGER, 53 | # ss_store_sk INTEGER, 54 | # ss_promo_sk INTEGER, 55 | # ss_ticket_number INTEGER, 56 | # ss_quantity INTEGER, 57 | # ss_wholesale_cost FLOAT, 58 | # ss_list_price FLOAT, 59 | # ss_sales_price FLOAT, 60 | # ss_ext_discount_amt FLOAT, 61 | # ss_ext_sales_price FLOAT, 62 | # ss_ext_wholesale_cost FLOAT, 63 | # ss_ext_list_price FLOAT, 64 | # ss_ext_tax FLOAT, 65 | # ss_coupon_amt FLOAT, 66 | # ss_net_paid FLOAT, 67 | # ss_net_paid_inc_tax FLOAT, 68 | # ss_net_profit FLOAT) 69 | # TBLPROPERTIES( 70 | # 'hbaseTableName'='store_sales_htable', 71 | # 'keyCols'='ss_item_sk;ss_ticket_number', 72 | # 'nonKeyCols'='ss_sold_date_sk,f,ss_sold_date_sk; ss_sold_time_sk,f,ss_sold_time_sk; ss_customer_sk,f,ss_customer_sk; 73 | # ss_cdemo_sk,f,ss_cdemo_sk; ss_hdemo_sk,f,ss_hdemo_sk; ss_addr_sk,f,ss_addr_sk; ss_store_sk,f,ss_store_sk; 74 | # ss_promo_sk,f,ss_promo_sk;ss_quantity,f,ss_quantity; ss_wholesale_cost,f,ss_wholesale_cost; 75 | # ss_list_price,f,ss_list_price; ss_sales_price,f,ss_sales_price; ss_ext_discount_amt,f,ss_ext_discount_amt; 76 | # ss_ext_sales_price,f,ss_ext_sales_price; ss_ext_wholesale_cost,f,ss_ext_wholesale_cost; 77 | # ss_ext_list_price,f,ss_ext_list_price; ss_ext_tax,f,ss_ext_tax; ss_coupon_amt,f,ss_coupon_amt; 78 | # ss_net_paid,f,ss_net_paid; ss_net_paid_inc_tax,f,ss_net_paid_inc_tax; ss_net_profit,f,ss_net_profit') 79 | # 80 | # To create this table, cut and paste the following one-line command: 81 | # 82 | CREATE TABLE store_sales (ss_sold_date_sk INTEGER,ss_sold_time_sk INTEGER,ss_item_sk INTEGER,ss_customer_sk INTEGER,ss_cdemo_sk INTEGER,ss_hdemo_sk INTEGER,ss_addr_sk INTEGER,ss_store_sk INTEGER,ss_promo_sk INTEGER,ss_ticket_number INTEGER,ss_quantity INTEGER,ss_wholesale_cost FLOAT,ss_list_price FLOAT,ss_sales_price FLOAT,ss_ext_discount_amt FLOAT,ss_ext_sales_price FLOAT,ss_ext_wholesale_cost FLOAT,ss_ext_list_price FLOAT,ss_ext_tax FLOAT,ss_coupon_amt FLOAT,ss_net_paid FLOAT,ss_net_paid_inc_tax FLOAT,ss_net_profit FLOAT) TBLPROPERTIES('hbaseTableName'='store_sales_htable', 'keyCols'='ss_item_sk;ss_ticket_number', 'nonKeyCols'='ss_sold_date_sk,f,ss_sold_date_sk;ss_sold_time_sk,f,ss_sold_time_sk;ss_customer_sk,f,ss_customer_sk;ss_cdemo_sk,f,ss_cdemo_sk;ss_hdemo_sk,f,ss_hdemo_sk;ss_addr_sk,f,ss_addr_sk;ss_store_sk,f,ss_store_sk;ss_promo_sk,f,ss_promo_sk;ss_quantity,f,ss_quantity;ss_wholesale_cost,f,ss_wholesale_cost;ss_list_price,f,ss_list_price;ss_sales_price,f,ss_sales_price;ss_ext_discount_amt,f,ss_ext_discount_amt;ss_ext_sales_price,f,ss_ext_sales_price;ss_ext_wholesale_cost,f,ss_ext_wholesale_cost;ss_ext_list_price,f,ss_ext_list_price;ss_ext_tax,f,ss_ext_tax;ss_coupon_amt,f,ss_coupon_amt;ss_net_paid,f,ss_net_paid;ss_net_paid_inc_tax,f,ss_net_paid_inc_tax;ss_net_profit,f,ss_net_profit') 83 | 84 | 85 | 86 | # Step 3: create table customer 87 | # 88 | # CREATE TABLE customer ( 89 | # c_customer_sk INTEGER, 90 | # c_customer_id STRING, 91 | # c_current_cdemo_sk INTEGER, 92 | # c_current_hdemo_sk INTEGER, 93 | # c_current_addr_sk INTEGER, 94 | # c_first_shipto_date_sk INTEGER, 95 | # c_first_sales_date_sk INTEGER, 96 | # c_salutation STRING, 97 | # c_first_name STRING, 98 | # c_last_name STRING, 99 | # c_preferred_cust_flag STRING, 100 | # c_birth_day INTEGER, 101 | # c_birth_month INTEGER, 102 | # c_birth_year INTEGER, 103 | # c_birth_country STRING, 104 | # c_login STRING, 105 | # c_email_address STRING, 106 | # c_last_review_date_sk INTEGER) 107 | # TBLPROPERTIES( 108 | # 'hbaseTableName'='customer_htable', 109 | # 'keyCols'='c_customer_sk', 110 | # 'nonKeyCols'='c_customer_id,f,c_customer_id; c_current_cdemo_sk,f,c_current_cdemo_sk; 111 | # c_current_hdemo_sk,f,c_current_hdemo_sk; c_current_addr_sk,f,c_current_addr_sk; 112 | # c_first_shipto_date_sk,f,c_first_shipto_date_sk; c_first_sales_date_sk,f,c_first_sales_date_sk; 113 | # c_salutation,f,c_salutation; c_first_name,f,c_first_name; 114 | # c_last_name,f,c_last_name;c_preferred_cust_flag,f,c_preferred_cust_flag; c_birth_day,f,c_birth_day; 115 | # c_birth_month,f,c_birth_month; c_birth_year,f,c_birth_year; c_birth_country,f,c_birth_country; 116 | # c_login,f,c_login; c_email_address,f,c_email_address; c_last_review_date_sk,f,c_last_review_date_sk') 117 | # 118 | # To create this table, cut and paste the following one-line command: 119 | # 120 | CREATE TABLE customer (c_customer_sk INTEGER, c_customer_id STRING, c_current_cdemo_sk INTEGER, c_current_hdemo_sk INTEGER, c_current_addr_sk INTEGER, c_first_shipto_date_sk INTEGER, c_first_sales_date_sk INTEGER, c_salutation STRING, c_first_name STRING, c_last_name STRING, c_preferred_cust_flag STRING, c_birth_day INTEGER, c_birth_month INTEGER, c_birth_year INTEGER, c_birth_country STRING, c_login STRING, c_email_address STRING, c_last_review_date_sk INTEGER) TBLPROPERTIES('hbaseTableName'='customer_htable', 'keyCols'='c_customer_sk', 'nonKeyCols'='c_customer_id,f,c_customer_id;c_current_cdemo_sk,f,c_current_cdemo_sk;c_current_hdemo_sk,f,c_current_hdemo_sk;c_current_addr_sk,f,c_current_addr_sk;c_first_shipto_date_sk,f,c_first_shipto_date_sk;c_first_sales_date_sk,f,c_first_sales_date_sk;c_salutation,f,c_salutation;c_first_name,f,c_first_name;c_last_name,f,c_last_name;c_preferred_cust_flag,f,c_preferred_cust_flag;c_birth_day,f,c_birth_day;c_birth_month,f,c_birth_month;c_birth_year,f,c_birth_year;c_birth_country,f,c_birth_country;c_login,f,c_login;c_email_address,f,c_email_address;c_last_review_date_sk,f,c_last_review_date_sk') 121 | 122 | 123 | 124 | # Step 4: create table customer_address 125 | # 126 | # CREATE TABLE customer_address ( 127 | # ca_address_sk INTEGER, 128 | # ca_address_id STRING, 129 | # ca_street_number STRING, 130 | # ca_street_name STRING, 131 | # ca_stret_type STRING, 132 | # ca_suite_number STRING, 133 | # ca_city STRING, 134 | # ca_county STRING, 135 | # ca_state STRING, 136 | # ca_zip STRING, 137 | # ca_country STRING, 138 | # ca_gmt_offset FLOAT, 139 | # ca_location_type STRING) 140 | # TBLPROPERTIES( 141 | # 'hbaseTableName'='customer_address_htable', 142 | # 'keyCols'='ca_address_sk', 143 | # 'nonKeyCols'='ca_address_id,f,ca_address_id; ca_street_number,f,ca_street_number; ca_street_name,f,ca_street_name; 144 | # ca_stret_type,f,ca_stret_type; ca_suite_number,f,ca_suite_number; ca_city,f,ca_city;ca_county,f,ca_county; 145 | # ca_state,f,ca_state; ca_zip,f,ca_zip; ca_country,f,ca_country; ca_gmt_offset,f,ca_gmt_offset; 146 | # ca_location_type,f,ca_location_type') 147 | # 148 | # To create this table, cut and paste the following one-line command: 149 | # 150 | CREATE TABLE customer_address (ca_address_sk INTEGER, ca_address_id STRING, ca_street_number STRING, ca_street_name STRING, ca_stret_type STRING, ca_suite_number STRING, ca_city STRING, ca_county STRING, ca_state STRING, ca_zip STRING, ca_country STRING, ca_gmt_offset FLOAT, ca_location_type STRING) TBLPROPERTIES('hbaseTableName'='customer_address_htable', 'keyCols'='ca_address_sk', 'nonKeyCols'='ca_address_id,f,ca_address_id;ca_street_number,f,ca_street_number;ca_street_name,f,ca_street_name;ca_stret_type,f,ca_stret_type;ca_suite_number,f,ca_suite_number;ca_city,f,ca_city;ca_county,f,ca_county;ca_state,f,ca_state;ca_zip,f,ca_zip;ca_country,f,ca_country;ca_gmt_offset,f,ca_gmt_offset;ca_location_type,f,ca_location_type') 151 | 152 | 153 | 154 | # Step 5: create table store 155 | # 156 | # CREATE TABLE store ( 157 | # s_store_sk INTEGER, 158 | # s_store_id STRING, 159 | # s_rec_start_date LONG, 160 | # s_rec_end_date LONG, 161 | # s_closed_date_sk INTEGER, 162 | # s_store_name STRING, 163 | # s_number_employees INTEGER, 164 | # s_floor_space INTEGER, 165 | # s_hours STRING, 166 | # s_manager STRING, 167 | # s_market_id INTEGER, 168 | # s_geography_class STRING, 169 | # s_market_desc STRING, 170 | # s_market_manager STRING, 171 | # s_division_id INTEGER, 172 | # s_division_name STRING, 173 | # s_company_id INTEGER, 174 | # s_company_name STRING, 175 | # s_street_number STRING, 176 | # s_street_name STRING, 177 | # s_street_type STRING, 178 | # s_suite_number STRING, 179 | # s_city STRING, 180 | # s_county STRING, 181 | # s_state STRING, 182 | # s_zip STRING, 183 | # s_country STRING, 184 | # s_gmt_offset FLOAT, 185 | # s_tax_percentage FLOAT) 186 | # TBLPROPERTIES( 187 | # 'hbaseTableName'='store_htable', 188 | # 'keyCols'='s_store_sk', 189 | # 'nonKeyCols'='s_store_id,f,s_store_id; s_rec_start_date,f,s_rec_start_date; s_rec_end_date,f,s_rec_end_date; 190 | # s_closed_date_sk,f,s_closed_date_sk; s_store_name,f,s_store_name; s_number_employees,f,s_number_employees; 191 | # s_floor_space,f,s_floor_space; s_hours,f,s_hours; s_manager,f,s_manager; s_market_id,f,s_market_id; 192 | # s_geography_class,f,s_geography_class; 193 | # s_market_desc,f,s_market_desc; s_market_manager,f,s_market_manager; s_division_id,f,s_division_id; 194 | # s_division_name,f,s_division_name; s_company_id,f,s_company_id; s_company_name,f,s_company_name; 195 | # s_street_number,f,s_street_number; s_street_name,f,s_street_name; s_street_type,f,s_street_type; 196 | # s_suite_number,f,s_suite_number; s_city,f,s_city; s_county,f,s_county; s_state,f,s_state; s_zip,f,s_zip; 197 | # s_country,f,s_country; s_gmt_offset,f,s_gmt_offset; s_tax_percentage,f,s_tax_percentage') 198 | # 199 | # To create this table, cut and paste the following one-line command: 200 | # 201 | CREATE TABLE store (s_store_sk INTEGER, s_store_id STRING, s_rec_start_date LONG, s_rec_end_date LONG, s_closed_date_sk INTEGER, s_store_name STRING, s_number_employees INTEGER, s_floor_space INTEGER, s_hours STRING, s_manager STRING, s_market_id INTEGER, s_geography_class STRING, s_market_desc STRING, s_market_manager STRING, s_division_id INTEGER, s_division_name STRING, s_company_id INTEGER, s_company_name STRING, s_street_number STRING, s_street_name STRING, s_street_type STRING, s_suite_number STRING, s_city STRING, s_county STRING, s_state STRING, s_zip STRING, s_country STRING, s_gmt_offset FLOAT, s_tax_percentage FLOAT) TBLPROPERTIES('hbaseTableName'='store_htable', 'keyCols'='s_store_sk', 'nonKeyCols'='s_store_id,f,s_store_id;s_rec_start_date,f,s_rec_start_date;s_rec_end_date,f,s_rec_end_date;s_closed_date_sk,f,s_closed_date_sk;s_store_name,f,s_store_name;s_number_employees,f,s_number_employees;s_floor_space,f,s_floor_space;s_hours,f,s_hours;s_manager,f,s_manager;s_market_id,f,s_market_id;s_geography_class,f,s_geography_class;s_market_desc,f,s_market_desc;s_market_manager,f,s_market_manager;s_division_id,f,s_division_id;s_division_name,f,s_division_name;s_company_id,f,s_company_id;s_company_name,f,s_company_name;s_street_number,f,s_street_number;s_street_name,f,s_street_name;s_street_type,f,s_street_type;s_suite_number,f,s_suite_number;s_city,f,s_city;s_county,f,s_county;s_state,f,s_state;s_zip,f,s_zip;s_country,f,s_country;s_gmt_offset,f,s_gmt_offset;s_tax_percentage,f,s_tax_percentage') 202 | --------------------------------------------------------------------------------