vaexio / vaex

Out-of-Core hybrid Apache Arrow/NumPy DataFrame for Python, ML, visualization and exploration of big tabular data at a billion rows per second 🚀
https://vaex.io
MIT License
8.23k stars 590 forks source link

[Bug Fix] Broken graphQL query comparisons #2356

Open BhaskarChezhiyan opened 1 year ago

BhaskarChezhiyan commented 1 year ago

Overview

graphQL queries with conditions that have an equal or not equal comparison with 0 as operand value are not evaluated properly.

Reproduce


import vaex
import pandas as pd
from decimal import Decimal

df = vaex.from_pandas(pd.Dataframe(data=[[7]], columns=['dummy'] ))

query = """
query($where: BoolExp!, $limit: Int!){
          df(where: $where) { row(limit: $limit){
                               dummy
                               }
                        }
                  }
"""
variables = {'limit': Decimal('10'), 'where': {'dummy': {'_eq': Decimal('0')}}}
output = df.graphql.execute(query, variable_values=variables)

print(output.errors)

Changes

  1. Added null check to Compare class _eq and _neq checks.
  2. Fixed BooleanCompare class to inherit from Compare class rather than NumberCompare.