bito-code-review[bot] commented on PR #42793:
URL: https://github.com/apache/superset/pull/42793#issuecomment-5189939353

   <!-- Bito Reply -->
   The review suggestion is correct. Testing the implementation by 
re-calculating the expected value using the same function (`hash_from_str`) as 
the production code creates a circular dependency, meaning the test would pass 
even if the hashing logic itself were broken. To resolve this, you should use a 
hardcoded, pre-computed hash value for the test inputs to ensure the 
implementation remains stable and correct.
   
   Here is how you can update the test to use fixed expected values:
   
   ```python
   def test_clickhouse_mutate_label_suffixes_hash() -> None:
       from superset.db_engine_specs.clickhouse import ClickHouseBaseEngineSpec
   
       # Pre-computed hashes for the labels
       assert ClickHouseBaseEngineSpec._mutate_label("create_time") == 
"create_time_b16a62"
       assert ClickHouseBaseEngineSpec._mutate_label("revenue") == 
"revenue_a1b2c3"
       assert ClickHouseBaseEngineSpec._mutate_label("sum(A)/sum(B)") == 
"sum(A)/sum(B)_d4e5f6"
   ```
   
   (Note: Please replace the placeholder hashes `b16a62`, `a1b2c3`, and 
`d4e5f6` with the actual correct hash outputs for those strings.)
   
   **tests/unit_tests/db_engine_specs/test_clickhouse.py**
   ```
   # Pre-computed hashes for the labels
       assert ClickHouseBaseEngineSpec._mutate_label("create_time") == 
"create_time_b16a62"
       assert ClickHouseBaseEngineSpec._mutate_label("revenue") == 
"revenue_a1b2c3"
       assert ClickHouseBaseEngineSpec._mutate_label("sum(A)/sum(B)") == 
"sum(A)/sum(B)_d4e5f6"
   ```


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