Skip to content

crandas.placeholders

Masked(values, *, modulus, size, json_rep=None, **kwargs)

Masked placeholder

Indicates that the provided value is masked when sending it to the server. Currently, for internal use only.

Constructor

PARAMETER DESCRIPTION
values

Values to be masked

Placeholder(value, *, label=None, session=None, **kwargs)

Placeholder placeholder

When used as an argument to a VDL query command that is authorized, indicates that the authorization applies to any possible value. For example, filtering with ==32 means that only filtering for equality to the specific value 32 is authorized; filtering with ==Placeholder(32) means that filtering with any value instead of the concrete value 32 is authorized.

The Placeholder placeholder does not tie the data type, e.g., when using an integer placeholder Placeholder(1) in script recording, this also authorizes the use of a fixed-point value 2.0 when playing the script. However, the Placeholder placeholder only allows to insert values, and not more complex expressions, e.g., when using the placeholder Placeholder(1) in script recording, this does not authorize the use of e.g. a column reference cdf["col1"].

A placeholder needs to consistently have the same value. That is, when the same placeholder object (or different placeholder objects that have the same label) is used multiple times in a script, the placeholder has to have the same value. This does not apply outside of the context of a script, or when the placeholder is defined in a stepless context. For example:

cd.script.record()

p1 = cd.Placeholder(1)
cdf = cdf.filter(cdf["x"] == p1)

p2 = cd.Placeholder(2)

with cd.script.stepless():
    p3 = cd.Placeholder(3)

    # Allows to do .isin(xx, yy, zz), where xx has to be the same as in the
    # previous filter; yy has to be the same for the different calls to
    # .isin; and zz can be arbitrary
    cdf = cdf.filter(cdf["z"].isin([p1, p2, p3]))

Any(*args, **kwargs)

Deprecated

Use Placeholder instead.

get_recording_encoder(*, session, dry_run)

Encodes a JSON for recording the query

  • In objects, values that are are None or MISSING are not included (to support JSON null, use a custom object and handle it in the 'default' function below)
  • For placeholders and masked values, a placeholder is produced
  • References are encoded using .to_json

get_send_encoder(*, session)

Encodes a JSON for sending the query.

  • In objects, values that are are None or MISSING are not included (to support JSON null, use a custom object and handle it in the 'default' function below)
  • For placeholders, concrete values are encoded
  • For masked values, the json_rep is returned (actual values are uploaded as streaming data)
  • References are encoded using .to_json