milenkovicm commented on code in PR #2588:
URL: 
https://github.com/apache/datafusion-ballista/pull/2588#discussion_r4376503139


##########
python/python/tests/test_config.py:
##########
@@ -0,0 +1,194 @@
+# 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.
+
+import pytest
+
+from ballista._internal_ballista import (
+    BallistaConfigExtension,
+    ballista_datafusion_config_defaults,
+)
+from ballista.extension import (
+    _BALLISTA_RESTRICTED_DATAFUSION_OPTIONS,
+    _produce_valid_config,
+)
+from datafusion import SessionConfig, SessionContext
+
+
+def _settings(config: SessionConfig) -> dict:
+    ctx = SessionContext(config)
+    ctx.sql("SET datafusion.catalog.information_schema = true").collect()
+    rows = ctx.sql("SELECT name, value FROM 
information_schema.df_settings").to_pylist()
+    return {row["name"]: row["value"] for row in rows}
+
+
+def test_restricted_options_set_without_config():
+    defaults = ballista_datafusion_config_defaults()
+    settings = _settings(_produce_valid_config())
+
+    for key in _BALLISTA_RESTRICTED_DATAFUSION_OPTIONS:
+        assert settings[key] == defaults[key], key
+
+
+def test_restricted_options_override_user_config():
+    config = SessionConfig().set("datafusion.optimizer.prefer_hash_join", 
"true")
+    settings = _settings(_produce_valid_config(config))
+
+    assert settings["datafusion.optimizer.prefer_hash_join"] == "false"
+
+
+def test_round_robin_repartition_disabled_without_config():
+    settings = _settings(_produce_valid_config())
+
+    assert settings["datafusion.optimizer.enable_round_robin_repartition"] == 
"false"
+
+
+def test_round_robin_repartition_disabled_with_user_config():
+    config = SessionConfig().set(
+        "datafusion.optimizer.enable_round_robin_repartition", "true"
+    )
+    settings = _settings(_produce_valid_config(config))
+
+    assert settings["datafusion.optimizer.enable_round_robin_repartition"] == 
"false"
+
+
+def test_non_restricted_options_kept_from_user_config():
+    config = SessionConfig().with_target_partitions(3).with_batch_size(1234)
+    settings = _settings(_produce_valid_config(config))
+
+    assert settings["datafusion.execution.target_partitions"] == "16"

Review Comment:
   this is going to be a bit of issue, lets find the most ergonomic way to do 
this. we can discuss in follow up PR 



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to