deephaven / deephaven-docs-community

Source code for Community docs on the deephaven.io website.
Apache License 2.0
0 stars 5 forks source link

feat: Added query library functions to overload Period and Duration arithmetic #237

Closed deephaven-internal closed 2 months ago

deephaven-internal commented 3 months ago

This issue was auto-generated

PR: https://github.com/deephaven/deephaven-core/pull/5509 Author: chipkent

Original PR Body

Added query library functions to overload Period and Duration arithmetic.

from deephaven import empty_table
t2 = empty_table(10).update(["P = 'P2D'", "D = 'PT2h'"])

t3 = t2.update([
    "P2 = P * 2", "P3 = 2 * P", 
    "P4 = P * 2L", "P5 = 2L * P",
    # "P6 = P * 2.3", "P7 = 2.3 * P", # Not supported because it doesn't make sense
    # "P8 = P / 2", # Not supported because it doesn't make sense
    # "P9 = P / 2L", # Not supported because it doesn't make sense
    # "P10 = P * 2.3", # Not supported because it doesn't make sense
    "P11 = P + P",
    "P12 = P - P",
    ])

t4 = t2.update([
    "D2 = D * 2", "D3 = 2 * D", 
    "D4 = D * 2L", "D5 = 2L * D",
    # "D6 = D * 2.3", "D7 = 2.3 * D", # Floating point is not supported because it is not in the Java time lib
    "D8 = D / 2", 
    "D9 = D / 2L",
    # "D10 = D * 2.3", # Floating point is not supported because it is not in the Java time lib
    "D11 = D + D",
    "D12 = D - D",
    ])

t6 = t2.update("I = now() + P*2 + 2*P")
t7 = t2.update("I = now() + D*2 + D/2")

Resolves #5379