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

[IMP] compiler #4088

Closed
wants to merge 2 commits into from
Closed

[IMP] compiler #4088

wants to merge 2 commits into from

Conversation

LucasLefevre
Copy link
Collaborator

Description:

description of this task, what is implemented and why it is implemented that way.

Task: : TASK_ID

review checklist

  • feature is organized in plugin, or UI components
  • support of duplicate sheet (deep copy)
  • in model/core: ranges are Range object, and can be adapted (adaptRanges)
  • in model/UI: ranges are strings (to show the user)
  • undo-able commands (uses this.history.update)
  • multiuser-able commands (has inverse commands and transformations where needed)
  • new/updated/removed commands are documented
  • exportable in excel
  • translations (_t("qmsdf %s", abc))
  • unit tested
  • clean commented code
  • track breaking changes
  • doc is rebuild (npm run doc)
  • status is correct in Odoo

@robodoo
Copy link
Collaborator

robodoo commented Apr 16, 2024

@LucasLefevre LucasLefevre force-pushed the master-reffn-single-cells-lul branch 4 times, most recently from 5409498 to dcb43e9 Compare April 17, 2024 08:50
@LucasLefevre LucasLefevre force-pushed the master-reffn-single-cells-lul branch 3 times, most recently from f875643 to 038cf74 Compare April 18, 2024 14:38
@laa-odoo laa-odoo force-pushed the master-reffn-single-cells-lul branch from 038cf74 to 4865a88 Compare April 19, 2024 12:48
LucasLefevre and others added 2 commits April 23, 2024 09:46
Steps to reproduce:
- type in a cell `=IFERROR(ADD(A1:A2,1),456)`
=> the cell value is #ERROR instead of 456.

The compiled formulas use to functions to get the values of references
- `ref` returns a single value from a single cell
- `range` returns a matrix of values

Currently, the compiler chooses `ref` or `range` based on the function arg.
e.g. for 'ADD(..., ...)', the compiler would choose `ref` because ADD only
accepts single cell values. If the user typed `ADD(A1:A3, 2)`, `ref` currently
checks the range size and throw an error if it's not a single cell. That
causes the entire compiled function to fail.
Notably: '=IFERROR(ADD(A1:A2,1), 45)' results in an error instead of 45.

One key observation is that `ref` is actually useless from a functional POV.
We could always use `range` no matter the shape of the arguments. There's
already a check for the input sizes for each sub-function (think of
'ADD(TRANSPOSE(...), 5)'. There is a performance issue though because `range`
always builds a 2D matrix. A POC was done to remove `ref` entirely and only
use `range` but it showed 2x increase of the evaluation time of the large
formula dataset.
With this commit, we keep `ref` and use it every time the reference is a single
cell, and (importantly) only in this case.

The logic of errors
===================

There are two types of errors in formulas:
- structural/compilation errors:
    If the formula will *never* be correct, no matter what changes in the spreadsheet,
    for example `=TODAY(456)` will never work because `TODAY` will never accept
    any argument.
    Those errors cannot be caught by IFERROR for a functional reason:
    warn the user the formula is wrong (and will always be) and that he should
    fix it.
- evaluation errors:
   Any other error (divisiion by zero, wrong type). They can be caught by
   IFERROR.
   In the context of this PR: `ADD(A1:A2,1)` is invalid because `ADD` does not
   accepts ranges. But it can become valid if row 2 is deleted.

Task: 3859327
Co-authored-by: Alexis Lacroix <[email protected]>
Steps to reproduce:
- make sure no sheet is named qsqdfq
- type in a cell: `=IFERROR(qsqdfq!A1, 45)`
=> the cell value is #ERROR instead of 45

Task: 3597039
@rrahir rrahir force-pushed the master-reffn-single-cells-lul branch from 4865a88 to 768db7c Compare April 23, 2024 07:46
@rrahir
Copy link
Collaborator

rrahir commented Apr 23, 2024

@robodoo r+

@LucasLefevre
Copy link
Collaborator Author

robodoo rebase-ff :)

@robodoo
Copy link
Collaborator

robodoo commented Apr 23, 2024

Merge method set to rebase and fast-forward.

robodoo pushed a commit that referenced this pull request Apr 23, 2024
Steps to reproduce:
- type in a cell `=IFERROR(ADD(A1:A2,1),456)`
=> the cell value is #ERROR instead of 456.

The compiled formulas use to functions to get the values of references
- `ref` returns a single value from a single cell
- `range` returns a matrix of values

Currently, the compiler chooses `ref` or `range` based on the function arg.
e.g. for 'ADD(..., ...)', the compiler would choose `ref` because ADD only
accepts single cell values. If the user typed `ADD(A1:A3, 2)`, `ref` currently
checks the range size and throw an error if it's not a single cell. That
causes the entire compiled function to fail.
Notably: '=IFERROR(ADD(A1:A2,1), 45)' results in an error instead of 45.

One key observation is that `ref` is actually useless from a functional POV.
We could always use `range` no matter the shape of the arguments. There's
already a check for the input sizes for each sub-function (think of
'ADD(TRANSPOSE(...), 5)'. There is a performance issue though because `range`
always builds a 2D matrix. A POC was done to remove `ref` entirely and only
use `range` but it showed 2x increase of the evaluation time of the large
formula dataset.
With this commit, we keep `ref` and use it every time the reference is a single
cell, and (importantly) only in this case.

The logic of errors
===================

There are two types of errors in formulas:
- structural/compilation errors:
    If the formula will *never* be correct, no matter what changes in the spreadsheet,
    for example `=TODAY(456)` will never work because `TODAY` will never accept
    any argument.
    Those errors cannot be caught by IFERROR for a functional reason:
    warn the user the formula is wrong (and will always be) and that he should
    fix it.
- evaluation errors:
   Any other error (divisiion by zero, wrong type). They can be caught by
   IFERROR.
   In the context of this PR: `ADD(A1:A2,1)` is invalid because `ADD` does not
   accepts ranges. But it can become valid if row 2 is deleted.

Task: 3859327
Part-of: #4088
Co-authored-by: Alexis Lacroix <[email protected]>
robodoo pushed a commit that referenced this pull request Apr 23, 2024
Steps to reproduce:
- make sure no sheet is named qsqdfq
- type in a cell: `=IFERROR(qsqdfq!A1, 45)`
=> the cell value is #ERROR instead of 45

closes #4088

Task: 3597039
Signed-off-by: Rémi Rahir (rar) <[email protected]>
@robodoo robodoo closed this Apr 23, 2024
@robodoo robodoo added the 17.3 label Apr 23, 2024
@fw-bot fw-bot deleted the master-reffn-single-cells-lul branch May 7, 2024 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants