Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds unary, logical, binary arithmetic, and concat operators #1325

Merged
merged 6 commits into from
Jan 5, 2024

Conversation

johnedquinn
Copy link
Member

Relevant Issues

  • None

Description

  • Adds:
    • Logical Operators (NOT, AND, OR)
    • Unary Operators (POS, NEG)
    • Binary Arithmetic Operators (PLUS, MINUS, TIMES, DIV, MOD, BITWISE-AND)
    • Concat Operator

Other Information

License Information

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@johnedquinn johnedquinn marked this pull request as ready for review December 22, 2023 19:32
@johnedquinn johnedquinn requested a review from rchowell December 22, 2023 19:32
Copy link

github-actions bot commented Dec 22, 2023

Conformance comparison report

Base (c7466e4) 3955836 +/-
% Passing 92.54% 92.54% 0.00%
✅ Passing 5384 5384 0
❌ Failing 434 434 0
🔶 Ignored 0 0 0
Total Tests 5818 5818 0

Number passing in both: 5384

Number failing in both: 434

Number passing in Base (c7466e4) but now fail: 0

Number failing in Base (c7466e4) but now pass: 0

@codecov-commenter
Copy link

codecov-commenter commented Dec 22, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

❗ No coverage uploaded for pull request base (partiql-plugin-impl@c7466e4). Click here to learn what that means.

Additional details and impacted files
@@                  Coverage Diff                   @@
##             partiql-plugin-impl    #1325   +/-   ##
======================================================
  Coverage                       ?   49.27%           
  Complexity                     ?     1046           
======================================================
  Files                          ?      166           
  Lines                          ?    13395           
  Branches                       ?     2504           
======================================================
  Hits                           ?     6600           
  Misses                         ?     6138           
  Partials                       ?      657           
Flag Coverage Δ
CLI 11.86% <0.00%> (?)
EXAMPLES 80.28% <0.00%> (?)
LANG 54.71% <0.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -14,6 +22,8 @@ import org.partiql.value.PartiQLValueType.INT16
import org.partiql.value.PartiQLValueType.INT32
import org.partiql.value.PartiQLValueType.INT64
import org.partiql.value.PartiQLValueType.INT8
import java.math.BigDecimal
import java.math.BigInteger

@OptIn(PartiQLValueExperimental::class, PartiQLFunctionExperimental::class)
internal object FnDivide0 : PartiQLFunction.Scalar {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure these handle divide by zero, but perhaps that's out-of-scope for the initial PR. I think using reified type parameters would allow using the operators rather than a function call

binaryOpInt8(args) { lhs, rhs ->
   if (rhs == 0) {
         // handle error
   }
   val result = lhs / rhs
   return int8Value(result)
}

Not sure that code works for byte division, but the point is to pass our own block rather than Byte::div so we can handle the unpacked arguments ourselves on a per-function basis. See check for an example

@rchowell rchowell force-pushed the partiql-plugin-impl branch from 21180d7 to f129381 Compare December 22, 2023 21:13
@johnedquinn johnedquinn changed the title Adds unary, logicalm binary arithmetic, and concat operators Adds unary, logical, binary arithmetic, and concat operators Jan 5, 2024
@johnedquinn johnedquinn marked this pull request as draft January 5, 2024 19:32
Copy link
Contributor

@rchowell rchowell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This all looks good. Note that it does assume we are doing null call handling in the call operator within eval. This assumption is probably the right call so that every operator doesn't have to repeat logic

@rchowell rchowell marked this pull request as ready for review January 5, 2024 21:08
@johnedquinn johnedquinn merged commit c5dae43 into partiql-plugin-impl Jan 5, 2024
10 checks passed
@johnedquinn johnedquinn deleted the operator-impls branch January 5, 2024 21:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants