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

feat(minato): first-class sql json type #43

Merged
merged 50 commits into from
Nov 9, 2023
Merged

Conversation

Hieuzest
Copy link
Contributor

@Hieuzest Hieuzest commented Oct 26, 2023

Changes

  • revert part of fix: join groupBy, project aggr, joined field #42
    fix: aggr expr cannot be used in project / groupBy extra
  • define Modifer.group as nullable, split Selection.project & Selection.groupBy
    use Selection.groupBy({}, extra) to perform a full grouping
isNullable(sel.args[0].group) -> project -> only allow non-aggr evalops
else -> groupBy -> only allow aggr evalops

priority: aggr -> non-aggr (the first/most outer aggr will be used)
  • remove Dict<string> from types of Selection.table to enforce model passing

Features

  • $.object(non-aggr)
    project multiple fields into single column as json object
$.object({
	x: row => row.id,
	...
})
// shortcut model passing
$.object(row)
$.object(row.bar)
  • $.array(aggr)
    aggregate single column table into json array
  • $.sum,$.avg,$.max,$.min(non-aggr)
    perform array ops on json array
  • $.length (aggr & non-aggr)
    the count/length without distinct
  • $.in,$.nin(non-aggr)
    support $.in(row.value, row.array)
  • query op $size, $el support json array. thus we may safely deprecate list now

Bugfix / Enhancement

  • database.join convert Keys to Selection so that model can pass through
  • Project and other stages will preserve type for json and list fields now

Tasks

  • issue for maria10.5
  • basic .$object, $array
  • sugar for $.object
  • Add extra eval operations for processing json type
  • map/subquery embeded not planned
  • list type related

@codecov
Copy link

codecov bot commented Oct 26, 2023

Codecov Report

Merging #43 (94a9512) into master (05ea030) will increase coverage by 0.27%.
The diff coverage is 99.76%.

@@            Coverage Diff             @@
##           master      #43      +/-   ##
==========================================
+ Coverage   98.23%   98.51%   +0.27%     
==========================================
  Files          23       24       +1     
  Lines        4880     5594     +714     
  Branches     1206     1416     +210     
==========================================
+ Hits         4794     5511     +717     
+ Misses         86       83       -3     
Files Coverage Δ
packages/core/src/driver.ts 97.44% <100.00%> (+2.55%) ⬆️
packages/core/src/eval.ts 97.51% <100.00%> (+0.44%) ⬆️
packages/core/src/model.ts 96.31% <100.00%> (ø)
packages/core/src/selection.ts 96.93% <100.00%> (+0.02%) ⬆️
packages/memory/src/index.ts 99.40% <100.00%> (-0.06%) ⬇️
packages/mongo/src/utils.ts 98.91% <100.00%> (+0.08%) ⬆️
packages/sql-utils/src/index.ts 98.64% <100.00%> (+0.45%) ⬆️
packages/sqlite/src/index.ts 97.26% <100.00%> (+0.32%) ⬆️
packages/tests/src/index.ts 100.00% <100.00%> (ø)
packages/tests/src/json.ts 100.00% <100.00%> (ø)
... and 3 more

... and 1 file with indirect coverage changes

📣 Codecov offers a browser extension for seamless coverage viewing on GitHub. Try it in Chrome or Firefox today!

@Hieuzest Hieuzest marked this pull request as draft October 28, 2023 11:27
@Hieuzest Hieuzest changed the title feat: runtimeType, $.object, $.array feat: first level json type and runtimeType support Oct 28, 2023
@Hieuzest Hieuzest changed the title feat: first level json type and runtimeType support feat: first-class json type and runtimeType support Oct 28, 2023
@Hieuzest Hieuzest changed the title feat: first-class json type and runtimeType support feat: first-class sql json type Oct 29, 2023
@Hieuzest Hieuzest marked this pull request as ready for review October 29, 2023 18:16
@Hieuzest
Copy link
Contributor Author

Hieuzest commented Nov 5, 2023

PTAL @shigma

packages/core/src/eval.ts Outdated Show resolved Hide resolved
packages/core/src/eval.ts Outdated Show resolved Hide resolved
Co-authored-by: Shigma <shigma10826@gmail.com>
@shigma shigma merged commit 9208ce5 into cordiverse:master Nov 9, 2023
@shigma shigma changed the title feat: first-class sql json type feat(minato): first-class sql json type Nov 9, 2023
@Hieuzest Hieuzest deleted the dev-type branch November 23, 2023 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants