Giter Site home page Giter Site logo

olapscript's People

Contributors

hawkfish avatar presentoccupant avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

presentoccupant

olapscript's Issues

typeerror when running testDuplicateNames

Running testDuplicateNames in olapscript-tests-and-utils and get the following error:

TypeError: Cannot read property 'map' of undefined
(anonymous) @ olapscript.gs:1512
Table.groupby @ olapscript.gs:1511
testDuplicateNames @ olapscript-tests-and-utils.gs:136

Handle Duplicate column names

Unlike database tables, Sheets can have duplicate column names. We should handle this gracefully by numbering the duplicates.

Not referencing the column correctly, apparently

Please refer to the code in "ELR code.gs" - it's choking on the "where" clause and I'm having difficulty understanding why it doesn't like my RefExpr in my FuncExpr declaration. (I realize you would likely not implement this routine quite this way, but it's nevertheless a good exercise.)

query request

Suppose you had a table that contained the following fields:
timestamp, firstName, lastName, email, date, field1, field2, invalidTimestamp,

and you wanted to implement:
select firstName, lastName, email, date, field1, field2 where
firstName = <fname> and
lastName = <lname> and
email = <email> and
date = <some date> and
invalidTimestamp <hasn't been set...so is "", or is null, or whatever the best way to indicate an unset timestamp would be>

What would that query look like?

ReferenceError: Unknown column: Email

Please take a look at the mailchimp example in the ".pol" account. Are lines 18 and 25 correct? If so, the code throws the error in the subject line. If not, please indicate what needs to be different.

Cast operations

We should add a cast function that takes a type as the second argument.

Case statements

Supporting CASE includes handling short circuits, which can be valuable.

Basic SQL expression parser

If we ignore infix operators (+, AND, etc.) it is pretty straightforward to build an expression parser for SQL. The infix operations will need to be expressed as functions (e.g., AND(condition1, ...).

The main syntactic issue will just be that in SQL double quotes are used to delimit identifiers/references and single quotes are used for strings. So if an expression needs both, it will have to be written using JavaScript's triple-quote mechanism.

Add arithmetic functions

Most notably the ones used by an expression parser:

  • plus (will also concatenate strings)
  • minus
  • times
  • divide
  • div (integer division)
  • mod
  • power
  • negate (unary minus)

toSheet should only clear the range to be written

The more I think about it, the more I think that .toSheet shouldn't clear an entire sheet; it should just clear the range that will be written, even if that range always starts at A1. At any rate, the utility of .toSheet is limited because it clears the entire sheet. That said, clearing the entire sheet also seems like useful behavior, so maybe we want .toSheetRange in addition to .toSheet.

BTW, I'd call this a close relative of #79, rather than a dupe, though you might see that differently.

New code in Wiki needs testing

Found and fixed one error (missing square bracket), but is there a problem with

.where(new FuncExpr(Expr.isnull, args: [name2]))

? Apps Script seems to think so.

Performance

Copying an entire sheet runs quite slowly on a sheet with ~180 rows and ~80 columns. Two possible culprits are:

const header = sheet.getRange(1, 1, 1, lastColumn);
this.ordinals.forEach((name, i) => header.getCell(1, i+1).setValue(name));

and

this.ordinals.forEach((name, cid) => that.selection.forEach((selid, rid) => range.getCell(rid + 1, cid + 1).setValue(that.namespace[name].data[selid])));

Table.getRow() is 0-based

...which would be fine, but it retrieves the first data row, so there isn't a way to retrieve the header row, should you want it.

ToSheet should have options for locating the output

Is there a way to specify where in a sheet a particular block of data (anything from a cell, to a row, to a column, to a 2-d range) gets written? It looks like .tosheet always starts at A1.

I guess this is another way of asking if there's the equivalent of setRow(s) and setColumn(s) methods.

consider re(un)factoring

The easiest way to incorporate this code into an Apps Script project is as a library, since it only needs to be maintained in one place that way. (Granted, you forfeit the ability to step into routines in the debugger.)

With Apps Script, each call to a library routine needs to be prefaced by the name of that library. This means that, if there are four files for olapscript, an Apps Script developer needs to be aware of which of the four files a particular routine lives in, so they can preface it with the correct library name.

For that reason, it might be preferable to have the code live in one file (say, "olapscript"), so that any call could be made by just prefacing it with that one prefix.

Can I refer to a column by its letter, rather than its header?

I have a situation in "Assign by Polling Place" sheet where I'm allowing up to five polling places to be assigned, but since the remaining four are optional, I only have a header name ("Polling place(s)") on the first column, column I. Can I refer to the subsequent columns by their letter, or do I have to name those columns?

Create function library

Scalar functions should be members of Expr. For starters, space trimming and current date/time will do.

Rudimentary workflow tasks

We need a couple of these:

  • Run tests on commit.
  • Run tests to prevent merge
  • Generate olapscript.gs artifact on merge instead of checking it in.

something's funky with limit

Using the testLimit code in olapscript-tests-and-utils:

.limit(5, 1) returned:
blank row
row 5
row 6
row 2
row 8

.limit (5, 5) returned:
row 8
row 10
row 9
row 11
row 12

.limit (5) returned:
blank row
row 5
row 6
row 2
row 8

getColumn() can return a column of the wrong length

If there is a table with unequal column lengths - e.g. Column A has 5 (non-header) rows and Column B has one (non-header) row - if I call getColumn() on column B, I'll get an array of length 5, with one value and four empty strings. Of course it isn't high priority, but it doesn't seem like it should be the expected behavior.

Comparison Functions

Since Javascript doesn't have functional versions of the comparison operators, the need to be added to Expr. These should include is(not)distinct and is(not)null

Implement the BETWEEN function

In a sheet that had, say, columns called date1 and date2, is there a "between" operator to get all rows where <date> is between date1 and date2?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.