Hive가 batch오리엔티드인데 반해
Phoeix는 real-time Query도 수행하도록 만든 빠른 레이어이다.
-query를 HBase scan으로 만들어 빠르게 수행한다.
-HBase API를 바로 사용도 가능.
==> 그냥 jdbc 드라이버+SQL지원 정도의 용도로 많이 사용한다.
-----------------------------------
Phoenix : RDB 레이어 over hBase.
- Query engine + Metadata 저장소.
- JDBC driver 제공.
- Hive와 같이 join등 제공.
<Secondary index 방식 3가지>
- write only / + append 방식
- global for read-heavy mutable data
- local for write-heavy mutable or immutable
각종 join모두 지원.
Phoenix Calcite ?
----View생성 from HBase 테이블: 이름 transactions, ColumnFamily:transactions일때
CREATE VIEW "TransactionHistory" (k VARCHAR primary key, "Transactions"."transactionId" VARCHAR);.
=> Select "transactionId" from "Transactions"
그리고 ALTER VIEW명령어로 column추가 가능.
REF
======Sqlline 사용한 shell 이용 방법====
$cd /usr/hdp/current/phoenix-client/bin/
$./sqlline.py
pnix> !tables
pnix> select * from MY.MY_TABLE
0: jdbc:phoenix:> help
!all Execute the specified SQL against all the current connections
!autocommit Set autocommit mode on or off
!batch Start or execute a batch of statements
!brief Set verbose mode off
!call Execute a callable statement
!close Close the current connection to the database
!closeall Close all current open connections
!columns List all the columns for the specified table
!commit Commit the current transaction (if autocommit is off)
!connect Open a new connection to the database.
!dbinfo Give metadata information about the database
!describe Describe a table
!dropall Drop all tables in the current database
!exportedkeys List all the exported keys for the specified table
!go Select the current connection
!help Print a summary of command usage
!history Display the command history
!importedkeys List all the imported keys for the specified table
!indexes List all the indexes for the specified table
!isolation Set the transaction isolation for this connection
!list List the current connections
!manual Display the SQLLine manual
!metadata Obtain metadata information
!nativesql Show the native SQL for the specified statement
!outputformat Set the output format for displaying results
(table,vertical,csv,tsv,xmlattrs,xmlelements)
!primarykeys List all the primary keys for the specified table
!procedures List all the procedures
!properties Connect to the database specified in the properties file(s)
!quit Exits the program
!reconnect Reconnect to the database
!record Record all output to the specified file
!rehash Fetch table and column names for command completion
!rollback Roll back the current transaction (if autocommit is off)
!run Run a script from the specified file
!save Save the current variabes and aliases
!scan Scan for installed JDBC drivers
!script Start saving a script to a file
!set Set a sqlline variable
=> !set maxWitdh 200 : Terminal 가로 출력 길이 세팅.
!sql Execute a SQL command
!tables List all the tables in the database
!typeinfo Display the type map for the current connection
!verbose Set verbose mode on