Skip to content

[Rel v0.2] Migrate to the new language version #90

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

Closed
wants to merge 19 commits into from
12 changes: 6 additions & 6 deletions cli-e2e-test/rel/city.rel
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
module import_config:city_data
def schema = {
:city, "string"
module import_config[:city_data]
def schema {
(:city, "string")
}

bound syntax:header
declare syntax(:header, __trail...) requires true
end

module city_data
def CITY_NAME[idx, row] = source_catalog:city_data[idx, :city, row]
def CITY_NAME[idx, row]: source_catalog[:city_data, idx, :city, row]
end

module city
def name = city_data:CITY_NAME[_, _]
def name { city_data[:CITY_NAME, _, _] }
end
56 changes: 32 additions & 24 deletions cli-e2e-test/rel/config/config1.rel
Original file line number Diff line number Diff line change
@@ -1,59 +1,67 @@
@inline
module export_config
module cities_csv
def data = city
def data { city }

def syntax:header = {
1, :name
def syntax[:header]: {
(1, :name)
}

declare partition_size
end

module devices_csv
def data = device
def data { device }

def syntax:header = {
1, :name
def syntax[:header]: {
(1, :name)
}

def partition_size = 512 // defines the upper bound (MB) for the size of a partition
def partition_size { 512 } // defines the upper bound (MB) for the size of a partition
end

module stores_csv
def data = store
def data { store }

def syntax:header = {
1, :name
def syntax[:header]: {
(1, :name)
}

def partition_size = 512 // defines the upper bound (MB) for the size of a partition
def partition_size { 512 } // defines the upper bound (MB) for the size of a partition
end

module products_csv
def data = product_info
def data { product_info }

def syntax:header = {
1, :name
def syntax[:header]: {
(1, :name)
}

declare partition_size
end

module device_seen_snapshot_csv
def data = device_seen_snapshot_updated
def data { device_seen_snapshot_updated }

def syntax:header = {
1, :device ;
2, :last_seen
def syntax[:header]: {
(1, :device) ;
(2, :last_seen)
}

declare partition_size
end

module users_csv
def data = user
def data { user }

def syntax:header = {
1, :name
def syntax[:header]: {
(1, :name)
}

declare partition_size
end
end

def part_resource_date_pattern = "^(.+)/data_dt=(?<date>[0-9]+)/(.+).(csv|json|jsonl)$"
def part_resource_index_pattern = "^(.+)/part-(?<shard>[0-9])-(.+).(csv|json|jsonl)$"
def part_resource_index_multiplier = 100000
def part_resource_date_pattern { "^(.+)/data_dt=(?<date>[0-9]+)/(.+).(csv|json|jsonl)$" }
def part_resource_index_pattern { "^(.+)/part-(?<shard>[0-9])-(.+).(csv|json|jsonl)$" }
def part_resource_index_multiplier { 100000 }
6 changes: 3 additions & 3 deletions cli-e2e-test/rel/config/config2.rel
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
def part_resource_date_pattern = "^(.+)/data_dt=(?<date>[0-9]+)/(.+).(csv|json|jsonl)$"
def part_resource_index_pattern = "^(.+)/part-(?<shard>[0-9])-(.+).(csv|json|jsonl)$"
def part_resource_index_multiplier = 100000
def part_resource_date_pattern { "^(.+)/data_dt=(?<date>[0-9]+)/(.+).(csv|json|jsonl)$" }
def part_resource_index_pattern { "^(.+)/part-(?<shard>[0-9])-(.+).(csv|json|jsonl)$" }
def part_resource_index_multiplier { 100000 }
14 changes: 8 additions & 6 deletions cli-e2e-test/rel/config/config3.rel
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
@inline
module export_config
module cities_csv
def data = city
def data { city }

def syntax:header = {
1, :name
def syntax[:header]: {
(1, :name)
}

declare partition_size
end
end

def part_resource_date_pattern = "^(.+)/data_dt=(?<date>[0-9]+)/(.+).(csv|json|jsonl)$"
def part_resource_index_pattern = "^(.+)/part-(?<shard>[0-9])-(.+).(csv|json|jsonl)$"
def part_resource_index_multiplier = 100000
def part_resource_date_pattern { "^(.+)/data_dt=(?<date>[0-9]+)/(.+).(csv|json|jsonl)$" }
def part_resource_index_pattern { "^(.+)/part-(?<shard>[0-9])-(.+).(csv|json|jsonl)$" }
def part_resource_index_multiplier { 100000 }
14 changes: 7 additions & 7 deletions cli-e2e-test/rel/device.rel
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
module import_config:device_data
def schema = {
:device, "string" ;
:IMEI, "int"
module import_config[:device_data]
def schema {
(:device, "string") ;
(:IMEI, "int")
}

bound syntax:header
declare syntax(:header, __trail...) requires true
end

module device_data
def DEVICE_NAME[idx, row] = source_catalog:device_data[idx, :device, row]
def DEVICE_NAME[idx, row]: source_catalog[:device_data, idx, :device, row]
end

module device
def name = device_data:DEVICE_NAME[_, _]
def name { device_data[:DEVICE_NAME, _, _] }
end
33 changes: 16 additions & 17 deletions cli-e2e-test/rel/device_seen.rel
Original file line number Diff line number Diff line change
@@ -1,42 +1,41 @@
module import_config:device_seen_snapshot
def schema = {
:device, "string" ;
:last_seen, "date"
module import_config[:device_seen_snapshot]
def schema {
(:device, "string") ;
(:last_seen, "date")
}

bound syntax:header
declare syntax(:header, __trail...) requires true

@inline
def row_key_map[R](idx, row, key) {
def row_key_map({R}, idx, row, key): {
^Device(R[idx, :device, row], key)
}
end

entity type Device = String
@inline def ^Device { make_entity_hash[{:"Device"}, {String}] }

/*
* device_seen snapshot is a snapshot of the last time a device was seen, which is
* essentially an aggregation over the snapshot data and the current day's data
* found in the `device` relation.
*/

def current_date = max[source:spans[_]]
def device_seen_today(n, t) {
device:name(n) and
def current_date { max[source[:spans, _]] }
def device_seen_today(n, t): {
device(:name, n) and
t = current_date
}

def device_last_seen[d] = max[t:
device_seen_today(d, t)
def device_last_seen[d]: max[(t): device_seen_today(d, t)
or
(
snapshot_catalog:device_seen_snapshot:device(key, d) and
snapshot_catalog:device_seen_snapshot:last_seen(key, t)
from key
exists((key) |
snapshot_catalog(:device_seen_snapshot, :device, key, d) and
snapshot_catalog(:device_seen_snapshot, :last_seen, key, t))
)
]

module device_seen_snapshot_updated
def device(k, d) { device_last_seen(d, _) and k = d }
def last_seen(d, t) { device_last_seen(d, t) }
def device(k, d): { device_last_seen(d, _) and k = d }
def last_seen(d, t): { device_last_seen(d, t) }
end
52 changes: 26 additions & 26 deletions cli-e2e-test/rel/json_schema_mapping.rel
Original file line number Diff line number Diff line change
Expand Up @@ -7,62 +7,62 @@
* following types: (string, int, decimal, and object).
*/

def JsonSourceConfigKey(k) { json_source_config(k, x...) from x... }
def JsonSourceConfigKey(k): json_source_config(k, _...)

@function
def json_source:value[src in JsonSourceConfigKey] = source_catalog[src, _, :value]
def json_source[:value, src in JsonSourceConfigKey]: source_catalog[src, _, :value]
@function
def json_source:child[src in JsonSourceConfigKey] = source_catalog[src, _, :child]
def json_source:root[src in JsonSourceConfigKey] = source_catalog[src, _, :root]
def json_source:array[src in JsonSourceConfigKey] = source_catalog[src, _, :array]
def json_source[:child, src in JsonSourceConfigKey]: source_catalog[src, _, :child]
def json_source[:root, src in JsonSourceConfigKey]: source_catalog[src, _, :root]
def json_source[:array, src in JsonSourceConfigKey]: source_catalog[src, _, :array]

@function
def json_source:value[src in JsonSourceConfigKey] = simple_source_catalog[src, :value]
def json_source[:value, src in JsonSourceConfigKey]: simple_source_catalog[src, :value]
@function
def json_source:child[src in JsonSourceConfigKey] = simple_source_catalog[src, :child]
def json_source:root[src in JsonSourceConfigKey] = simple_source_catalog[src, :root]
def json_source:array[src in JsonSourceConfigKey] = simple_source_catalog[src, :array]
def json_source[:child, src in JsonSourceConfigKey]: simple_source_catalog[src, :child]
def json_source[:root, src in JsonSourceConfigKey]: simple_source_catalog[src, :root]
def json_source[:array, src in JsonSourceConfigKey]: simple_source_catalog[src, :array]

/**
* [REKS] Note that json_source, json_hash, json_name_sym, and json_schema cannot
* be further consolidated into a container module because of limits on the
* use of metafication (i.e., the #(...) operator) inside recursive
* definitions.
*/
def json_hash(src, t, h, s) =
def json_hash(src, t, h, s):
exists((x) |
murmurhash3f(s, x) and
h = uint128_hash_value_convert[x] and
json_source_config(src, t, s)
from x
json_source_config(src, t, s))

def json_name_sym[src, x] = #(json_hash[src, _, x])
def json_name_sym[src, x]: ::std::mirror::lift[json_hash[src, _, x]]

module json_schema

def parent(src, y, x, z) { json_source:child(src, x, y, z) }
def parent(src, y, x, z): { json_source(:child, src, x, y, z) }

def value(src, r, o, val) {
def value(src, r, o, val): {
exists((t) |
parent(src, r, o, t) and
json_hash(src, :string, r, _) and
json_source:value(src, t, val) and
String(val)
from t
json_source(:value, src, t, val) and
String(val))
}

def value(src, r, o, v) {
def value(src, r, o, v): {
exists((t) |
parent(src, r, o, t) and
json_hash(src, :decimal, r, _) and
json_source:value(src, t, v) and
Float(v)
from t
json_source(:value, src, t, v) and
Float(v))
}

def value(src, r, o, v) {
def value(src, r, o, v): {
exists((t) |
parent(src, r, o, t) and
json_hash(src, :int, r, _) and
json_source:value(src, t, v) and
Int(v)
from t
json_source(:value, src, t, v) and
Int(v))
}

end
12 changes: 6 additions & 6 deletions cli-e2e-test/rel/product.rel
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
module import_config:product_data
def schema = {
:product, "string"
module import_config[:product_data]
def schema {
(:product, "string")
}

bound syntax:header
declare syntax(:header, __trail...) requires true
end

module product_data
def PRODUCT_NAME[idx, row] = source_catalog:product_data[idx, :product, row]
def PRODUCT_NAME[idx, row]: source_catalog[:product_data, idx, :product, row]
end

module product_info
def name = product_data:PRODUCT_NAME[_, _]
def name { product_data[:PRODUCT_NAME, _, _] }
end
36 changes: 18 additions & 18 deletions cli-e2e-test/rel/store.rel
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
def json_source_config:store_data:string = {
def json_source_config[:store_data, :string]: {
"storeId" ;
"storeName"
}

def json_source_config:store_data:object(k) {
store_data_metadata:object_or_value_key(k) and
not json_source_config:store_data:string(k)
def json_source_config(:store_data, :object, k): {
store_data_metadata(:object_or_value_key, k) and
not json_source_config(:store_data, :string, k)
}

module store_data_metadata

def object_or_value_key = covers[_]
def object_or_value_key { covers[_] }

def covers = {
"_root_", "storeId" ;
"_root_", "storeName"
def covers {
("_root_", "storeId") ;
("_root_", "storeName")
}

end

def store_data_value(t, o, v) =
json_schema:value:store_data(h, o, v) and
json_name_sym:store_data(h, t)
from h
def store_data_value(t, o, v):
exists((h) |
json_schema(:value, :store_data, h, o, v) and
json_name_sym(:store_data, h, t))

def store_data_object(t, o, v) =
json_schema:parent:store_data(h, o, v) and
json_name_sym:store_data(h, t)
from h
def store_data_object(t, o, v):
exists((h) |
json_schema(:parent, :store_data, h, o, v) and
json_name_sym(:store_data, h, t))

module store
def name = store_data_value:storeName[_]
end
def name { store_data_value[:storeName, _] }
end
Loading