|
| 1 | +================= |
| 2 | +Phoenix Connector |
| 3 | +================= |
| 4 | + |
| 5 | +The Phoenix connector allows querying data stored in HBase using Apache Phoenix. |
| 6 | + |
| 7 | +Compatibility |
| 8 | +------------- |
| 9 | + |
| 10 | +The Phoenix connector is compatible with all Phoenix versions starting from 4.14.1. |
| 11 | + |
| 12 | +Configuration |
| 13 | +------------- |
| 14 | + |
| 15 | +To configure the Phoenix connector, create a catalog properties file |
| 16 | +``etc/catalog/phoenix.properties`` with the following contents, |
| 17 | +replacing ``host1,host2,host3`` with a comma-separated list of the ZooKeeper |
| 18 | +nodes used for discovery of the HBase cluster: |
| 19 | + |
| 20 | +.. code-block:: none |
| 21 | +
|
| 22 | + connector.name=phoenix |
| 23 | + phoenix.connection-url=jdbc:phoenix:host1,host2,host3:2181:/hbase |
| 24 | + phoenix.config.resources=/path/to/hbase-site.xml |
| 25 | +
|
| 26 | +The optional paths to Hadoop resource files such as ``hbase-site.xml`` are used |
| 27 | +to load custom Phoenix client connection properties. |
| 28 | + |
| 29 | +Configuration Properties |
| 30 | +------------------------ |
| 31 | + |
| 32 | +The following configuration properties are available: |
| 33 | + |
| 34 | +================================================== ========== =================================================================================== |
| 35 | +Property Name Required Description |
| 36 | +================================================== ========== =================================================================================== |
| 37 | +``phoenix.connection-url`` Yes ``jdbc:phoenix[:zk_quorum][:zk_port][:zk_hbase_path]``. |
| 38 | + The ``zk_quorum`` is a comma separated list of ZooKeeper servers. |
| 39 | + The ``zk_port`` is the ZooKeeper port. The ``zk_hbase_path`` is the HBase |
| 40 | + root znode path, that is configurable using ``hbase-site.xml``. By |
| 41 | + default the location is ``/hbase`` |
| 42 | +``phoenix.config.resources`` No Comma-separated list of configuration files (e.g. ``hbase-site.xml``) to use for |
| 43 | + connection properties. These files must exist on the machines running Presto. |
| 44 | +================================================== ========== =================================================================================== |
| 45 | + |
| 46 | +Querying Phoenix Tables |
| 47 | +------------------------- |
| 48 | + |
| 49 | +The default empty schema in Phoenix maps to a schema named ``default`` in Presto. |
| 50 | +You can see the available Phoenix schemas by running ``SHOW SCHEMAS``:: |
| 51 | + |
| 52 | + SHOW SCHEMAS FROM phoenix; |
| 53 | + |
| 54 | +If you have a Phoenix schema named ``web``, you can view the tables |
| 55 | +in this schema by running ``SHOW TABLES``:: |
| 56 | + |
| 57 | + SHOW TABLES FROM phoenix.web; |
| 58 | + |
| 59 | +You can see a list of the columns in the ``clicks`` table in the ``web`` schema |
| 60 | +using either of the following:: |
| 61 | + |
| 62 | + DESCRIBE phoenix.web.clicks; |
| 63 | + SHOW COLUMNS FROM phoenix.web.clicks; |
| 64 | + |
| 65 | +Finally, you can access the ``clicks`` table in the ``web`` schema:: |
| 66 | + |
| 67 | + SELECT * FROM phoenix.web.clicks; |
| 68 | + |
| 69 | +If you used a different name for your catalog properties file, use |
| 70 | +that catalog name instead of ``phoenix`` in the above examples. |
| 71 | + |
| 72 | +Data types |
| 73 | +---------- |
| 74 | + |
| 75 | +The data type mappings are as follows: |
| 76 | + |
| 77 | +========================== ============ |
| 78 | +Phoenix Presto |
| 79 | +========================== ============ |
| 80 | +``BOOLEAN`` (same) |
| 81 | +``BIGINT`` (same) |
| 82 | +``INTEGER`` (same) |
| 83 | +``SMALLINT`` (same) |
| 84 | +``TINYINT`` (same) |
| 85 | +``DOUBLE`` (same) |
| 86 | +``FLOAT`` ``REAL`` |
| 87 | +``DECIMAL`` (same) |
| 88 | +``BINARY`` ``VARBINARY`` |
| 89 | +``VARBINARY`` (same) |
| 90 | +``DATE`` (same) |
| 91 | +``TIME`` (same) |
| 92 | +``VARCHAR`` (same) |
| 93 | +``CHAR`` (same) |
| 94 | +========================== ============ |
| 95 | + |
| 96 | +The Phoenix fixed length ``BINARY`` data type is mapped to the Presto |
| 97 | +variable length ``VARBINARY`` data type. There is no way to create a |
| 98 | +Phoenix table in Presto that uses the ``BINARY`` data type, as Presto |
| 99 | +does not have an equivalent type. |
| 100 | + |
| 101 | + |
| 102 | +Table Properties - Phoenix |
| 103 | +-------------------------- |
| 104 | + |
| 105 | +Table property usage example:: |
| 106 | + |
| 107 | + CREATE TABLE myschema.scientists ( |
| 108 | + recordkey VARCHAR, |
| 109 | + birthday DATE, |
| 110 | + name VARCHAR, |
| 111 | + age BIGINT |
| 112 | + ) |
| 113 | + WITH ( |
| 114 | + rowkeys = 'recordkey,birthday', |
| 115 | + salt_buckets = 10 |
| 116 | + ); |
| 117 | + |
| 118 | +The following are supported Phoenix table properties from `<https://phoenix.apache.org/language/index.html#options>`_ |
| 119 | + |
| 120 | +=========================== ================ ============================================================================================================== |
| 121 | +Property Name Default Value Description |
| 122 | +=========================== ================ ============================================================================================================== |
| 123 | +``rowkeys`` ``ROWKEY`` Comma-separated list of primary key columns. See further description below |
| 124 | + |
| 125 | +``split_on`` (none) List of keys to presplit the table on. |
| 126 | + See `Split Point <https://phoenix.apache.org/language/index.html#split_point>`_. |
| 127 | + |
| 128 | +``salt_buckets`` (none) Number of salt buckets for this table. |
| 129 | + |
| 130 | +``disable_wal`` false Whether to disable WAL writes in HBase for this table. |
| 131 | + |
| 132 | +``immutable_rows`` false Declares whether this table has rows which are write-once, append-only. |
| 133 | + |
| 134 | +``default_column_family`` ``0`` Default column family name to use for this table. |
| 135 | +=========================== ================ ============================================================================================================== |
| 136 | + |
| 137 | +``rowkeys`` |
| 138 | +^^^^^^^^^^^ |
| 139 | +This is a comma-separated list of columns to be used as the table's primary key. If not specified, a ``BIGINT`` primary key column named ``ROWKEY`` is generated |
| 140 | +, as well as a sequence with the same name as the table suffixed with ``_seq`` (i.e. ``<schema>.<table>_seq``) |
| 141 | +, which is used to automatically populate the ``ROWKEY`` for each row during insertion. |
| 142 | + |
| 143 | +Table Properties - HBase |
| 144 | +------------------------ |
| 145 | +The following are the supported HBase table properties that are passed through by Phoenix during table creation. |
| 146 | +Use them in the the same way as above: in the ``WITH`` clause of the ``CREATE TABLE`` statement. |
| 147 | + |
| 148 | +=========================== ================ ============================================================================================================== |
| 149 | +Property Name Default Value Description |
| 150 | +=========================== ================ ============================================================================================================== |
| 151 | +``versions`` ``1`` The maximum number of versions of each cell to keep. |
| 152 | + |
| 153 | +``min_versions`` ``0`` The minimum number of cell versions to keep. |
| 154 | + |
| 155 | +``compression`` ``NONE`` Compression algorithm to use. Valid values are ``NONE`` (default), ``SNAPPY``, ``LZO``, ``LZ4``, or ``GZ``. |
| 156 | + |
| 157 | +``ttl`` ``FOREVER`` Time To Live for each cell. |
| 158 | +``bloomfilter`` ``ROW`` Bloomfilter to use. Valid values are ``NONE``, ``ROW`` (default), or ``ROWCOL``. |
| 159 | +=========================== ================ ============================================================================================================== |
| 160 | + |
0 commit comments