You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2019/10/29 08:50:02 UTC

[GitHub] [airflow] sekikn opened a new pull request #6457: [AIRFLOW-5800] Add a default connection entry for PinotDbApiHook

sekikn opened a new pull request #6457: [AIRFLOW-5800] Add a default connection entry for PinotDbApiHook
URL: https://github.com/apache/airflow/pull/6457
 
 
   Make sure you have checked _all_ steps below.
   
   ### Jira
   
   - [x] My PR addresses the following [Airflow Jira](https://issues.apache.org/jira/browse/AIRFLOW/) issues and references them in the PR title. For example, "\[AIRFLOW-XXX\] My Airflow PR"
     - https://issues.apache.org/jira/browse/AIRFLOW-5800
     - In case you are fixing a typo in the documentation you can prepend your commit with \[AIRFLOW-XXX\], code changes always need a Jira issue.
     - In case you are proposing a fundamental code change, you need to create an Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvements+Proposals)).
     - In case you are adding a dependency, check if the license complies with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
   
   ### Description
   
   - [x] Here are some details about my PR, including screenshots of any UI changes:
   
   Airflow provides PinotDbApiHook but its default connection is not
   defined in the DB. This PR adds it for testing purposes and as an
   example, just like other hooks.
   
   
   ### Tests
   
   - [x] My PR adds the following unit tests __OR__ does not need testing for this extremely good reason:
   
   No additional test, since it's just adding an initial value to the connection table.
   Instead, I confirmed the existing `test_cli_initdb` test succeeded:
   
   ```
   $ ./run-tests tests.core:TestCli.test_cli_initdb
   
   (snip)
   
   Starting the tests with arguments: tests.core:TestCli.test_cli_initdb
   
   .
   ----------------------------------------------------------------------
   Ran 1 test in 3.942s
   
   OK
   ```
   
   And I also confirmed that the new database entry worked with a real Pinot cluster, as follows:
   
   ```
   $ curl -LO https://dist.apache.org/repos/dist/release/incubator/pinot/apache-pinot-incubating-0.1.0/apache-pinot-incubating-0.1.0-bin.tar.gz
   $ tar xfz apache-pinot-incubating-0.1.0-bin.tar.gz
   $ cd apache-pinot-incubating-0.1.0-bin
   $ nohup bin/pinot-admin.sh StartZookeeper &
   $ nohup bin/pinot-admin.sh StartController &
   $ nohup bin/pinot-admin.sh StartBroker &
   $ nohup bin/pinot-admin.sh StartServer &
   $ bin/pinot-admin.sh AddSchema -schemaFile sample_data/baseballStats_offline_table_config.json -exec
   $ bin/pinot-admin.sh AddTable -filePath sample_data/baseballStats_offline_table_config.json -exec
   $ bin/pinot-admin.sh CreateSegment -dataDir sample_data -outDir /tmp/outDir -tableName baseballStats -segmentName baseball -schemaFile sample_data/baseballStats_schema.json
   $ bin/pinot-admin.sh UploadSegment -segmentDir /tmp/outDir
   $ airflow db init
   
   (snip)
   
   Done.
   $ ipython
   
   (snip)
   
   In [2]: from airflow.contrib.hooks.pinot_hook import PinotDbApiHook                                                                                                          
   
   In [3]: hook = PinotDbApiHook()                                                                                                                                              
   
   In [4]: hook.get_first("SELECT * FROM baseballStats")                                                                                                                        
   [2019-10-29 01:37:33,596] {base_hook.py:89} INFO - Using connection to: id: pinot_broker_default. Host: localhost, Port: 8099, Schema: None, Login: None, Password: None, extra: {'endpoint': '/query', 'schema': 'http'}
   [2019-10-29 01:37:33,597] {pinot_hook.py:48} INFO - Get the connection to pinot broker on localhost
   SELECT * FROM baseballStats
   Out[4]: Row(AtBatting='0', G_old='0', baseOnBalls='0', caughtStealing='0', doules='0', groundedIntoDoublePlays='0', hits='0', hitsByPitch='0', homeRuns='0', intentionalWalks='0', league='null', numberOfGames='0', numberOfGamesAsBatter='0', playerID='null', playerName='null', playerStint='0', runs='0', runsBattedIn='0', sacrificeFlies='0', sacrificeHits='0', stolenBases='0', strikeouts='0', teamID='null', tripples='0', yearID='-2147483648')
   ```
   
   ### Commits
   
   - [x] My commits all reference Jira issues in their subject lines, and I have squashed multiple commits if they address the same issue. In addition, my commits follow the guidelines from "[How to write a good git commit message](http://chris.beams.io/posts/git-commit/)":
     1. Subject is separated from body by a blank line
     1. Subject is limited to 50 characters (not including Jira issue reference)
     1. Subject does not end with a period
     1. Subject uses the imperative mood ("add", not "adding")
     1. Body wraps at 72 characters
     1. Body explains "what" and "why", not "how"
   
   ### Documentation
   
   - [x] In case of new functionality, my PR adds documentation that describes how to use it.
     - All the public functions and the classes in the PR contain docstrings that explain what it does
     - If you implement backwards incompatible changes, please leave a note in the [Updating.md](https://github.com/apache/airflow/blob/master/UPDATING.md) so we can assign it to a appropriate release
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services