From ab38e6a032692878c732ed416c00dc86be5fc96b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Milenkovi=C4=87?= Date: Sun, 8 Dec 2024 15:43:37 +0000 Subject: [PATCH] cleanup examples --- .../examples/{remote.py => client_remote.py} | 8 ---- .../{standalone.py => client_standalone.py} | 0 python/examples/readme_remote.py | 38 +++++++++++++++++++ .../{readme.py => readme_standalone.py} | 2 +- 4 files changed, 39 insertions(+), 9 deletions(-) rename python/examples/{remote.py => client_remote.py} (79%) rename python/examples/{standalone.py => client_standalone.py} (100%) create mode 100644 python/examples/readme_remote.py rename python/examples/{readme.py => readme_standalone.py} (96%) diff --git a/python/examples/remote.py b/python/examples/client_remote.py similarity index 79% rename from python/examples/remote.py rename to python/examples/client_remote.py index e15d9d10a..fd85858ac 100644 --- a/python/examples/remote.py +++ b/python/examples/client_remote.py @@ -16,16 +16,8 @@ # under the License. # %% - from ballista import BallistaBuilder from datafusion.context import SessionContext - -# Ballista will initiate with an empty config -# set config variables with `config` -# ctx: SessionContext = BallistaBuilder()\ -# .config("ballista.job.name", "example ballista")\ -# .config("ballista.shuffle.partitions", "16")\ -# .standalone() ctx: SessionContext = BallistaBuilder().remote("df://127.0.0.1:50050") diff --git a/python/examples/standalone.py b/python/examples/client_standalone.py similarity index 100% rename from python/examples/standalone.py rename to python/examples/client_standalone.py diff --git a/python/examples/readme_remote.py b/python/examples/readme_remote.py new file mode 100644 index 000000000..7e1c82d83 --- /dev/null +++ b/python/examples/readme_remote.py @@ -0,0 +1,38 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# %% + +from ballista import BallistaBuilder +from datafusion.context import SessionContext + +ctx: SessionContext = BallistaBuilder()\ + .config("ballista.job.name", "Readme Example Remote")\ + .config("datafusion.execution.target_partitions", "4")\ + .remote("df://127.0.0.1:50050") + +ctx.sql("create external table t stored as parquet location '../testdata/test.parquet'") + +# %% +df = ctx.sql("select * from t limit 5") +pyarrow_batches = df.collect() +pyarrow_batches[0].to_pandas() +# %% +df = ctx.read_parquet('../testdata/test.parquet').limit(5) +pyarrow_batches = df.collect() +pyarrow_batches[0].to_pandas() +# %% \ No newline at end of file diff --git a/python/examples/readme.py b/python/examples/readme_standalone.py similarity index 96% rename from python/examples/readme.py rename to python/examples/readme_standalone.py index dcbdc3cc7..15404e02d 100644 --- a/python/examples/readme.py +++ b/python/examples/readme_standalone.py @@ -21,7 +21,7 @@ from datafusion.context import SessionContext ctx: SessionContext = BallistaBuilder()\ - .config("ballista.job.name", "Readme Examples")\ + .config("ballista.job.name", "Readme Example")\ .config("datafusion.execution.target_partitions", "4")\ .standalone()