Skip to content

FieldProp(refer): extend option refer with more features #331

@wenchy

Description

@wenchy

See https://tableauio.github.io/docs/excel/field-property/#option-refer

By default, refer means this column's values belongs to at least one of referred columns.

Current refer pattern: Sheet.Column[,Sheet.Column]..., we want to extend the pattern to be predicate(Sheet.Column[,Sheet.Column]...). Then it can be extended to support following features:

  • at-least-one and every-one
  • one-to-one mapping (bijective)

at-least-one and every-one

Use any when you mean “there exists at least one element meeting the condition.”
Use all when you mean “every element meets the condition.”

For example, Python programming (predicate over collections):

# at least one element satisfies predicate
if any(x > 0 for x in arr):
    print("at least one positive")

# each element satisfies predicate
if all(x > 0 for x in arr):
    print("all positive")

Proposed pattern: all(Sheet.Column[,Sheet.Column]...), By defaut, the pattern is any(Sheet.Column[,Sheet.Column]...)

one-to-one mapping (bijective)

If this feature is supported, then there is no need to support "at-least-one and every-one"?

  • Maybe we can extend the pattern to bijective(Sheet.Column[,Sheet.Column]...) to indicate that this column's values are one-to-one mapping to every one of referred columns.
  • Or just add an inverse refer option to the refered sheet column (In practice, we has used it very well).
  • Or add a new field property pair to signify the one-to-one mapping, and the pattern is just same as refer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions