MacOS(Mojave)でDatabricks koalasを利用しようとしてつまづいた
前提
What's "Koalas"?
- SparkのDataFrameの為にPandasライクなAPIを用意したのがKoalas
- 米国Databricks社が開発してOSSとして公開した、Python用のフレームワーク
- 米国Databricks社はApache Sparkを使った製品を開発・提供している(Sparkへのコミットもしている)
- SparkではPySparkと呼ばれるPythonからSparkを扱うためのツールが用意されている(Spark自体はJVM言語のScalaで開発されている)
- PySparkでDataFrameを用いる時はSparkが用意するものを使うのが高速
- 一方、PythonではDataFrameを扱うときは一般的にPandasを用いる
- PandasのDataFrameの書き方とSparkのDataFrameの書き方は異なり学習コストがかかる
つまづきポイント
Python 3.7.xでのpyarrowのバグを踏んだ
Github(https://github.com/databricks/koalas)のGet Startedに書いてるやんけ。 と言うことで、あらかじめ導入していたpyenvとvirtualenvを使って3.6.8の仮想環境を用意しよう。
If this fails to install the pyarrow dependency, you may want to try installing with Python 3.6.x, as pip install arrow does not work out of the box for 3.7 https://github.com/apache/arrow/issues/1125.
pyenvで3.6.xをインストールしようとするとCのヘッダーファイルがなかった
3.7.2入れた時にもハマりましたが、Xcodeをアップデートした時にまた元に戻った・・・のかな? http://kane-please.hatenablog.com/entry/2018/11/07/001823
cmakeの他にCythonやOpen JDKもいるやんけ
Dependencesに書いてないやん。当たり前なのか?
でも結局
In [1]: import databricks.koalas as ks In [2]: df = ks.DataFrame({'x':range(3), 'y':['a','b','b'], 'z':['a','b','b']}) WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by org.apache.spark.unsafe.Platform (file:/Users/tkm/.pyenv/versions/3.6.8/envs/mySpark/lib/python3.6/site-packages/pyspark/jars/spark-unsafe_2.12-2.4.2.jar) to method java.nio.Bits.unaligned() WARNING: Please consider reporting this to the maintainers of org.apache.spark.unsafe.Platform WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release 19/04/26 06:52:11 WARN NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable Using Spark's default log4j profile: org/apache/spark/log4j-defaults.properties Setting default log level to "WARN". To adjust logging level use sc.setLogLevel(newLevel). For SparkR, use setLogLevel(newLevel).
Docker でCentOS用意しよ…。