Skip to content

Commit

Permalink
Restructure Standard.Table. (#9559)
Browse files Browse the repository at this point in the history
Move the types from `Standard.Table.Data` to `Standard.Table`.

Exceptions:
- `Standard.Table.Data.Report_Unmatched` => `Standard.Table.Constants`.
- `Standard.Table.Data.Join_Kind_Cross` => `Standard.Table.Internal.Join_Kind_Cross`.
Also removed constructor as an atom type.
- `Standard.Table.Extensions.Table_Ref` => `Standard.Table.Internal.Table_Ref`.
- `Standard.Table.Data.Type.Value_Type_Helpers` => `Standard.Table.Internal.Value_Type_Helpers`.
- `Standard.Table.Data.Type.Enso_Types` => `Standard.Table.Internal.Value_Type_Helpers`.
- `Standard.Table.Data.Type.Storage` => `Standard.Table.Internal.Storage`.

Changed all `Standard.Table` imports inside project to be project.
Favoured importing from `Standard.Table.Main` in `Standard.Database`.
Also fixed some linting in Enso_File.
  • Loading branch information
jdunkerley authored Mar 27, 2024
1 parent 8f78668 commit e262801
Show file tree
Hide file tree
Showing 122 changed files with 503 additions and 539 deletions.
2 changes: 1 addition & 1 deletion app/gui2/e2e/tableVisualisation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { graphNodeByBinding } from './locate'
*/
async function initGraph(page: Page) {
await actions.goToGraph(page)
await mockExpressionUpdate(page, 'aggregated', { type: 'Standard.Table.Data.Table.Table' })
await mockExpressionUpdate(page, 'aggregated', { type: 'Standard.Table.Table.Table' })
}

/**
Expand Down
20 changes: 10 additions & 10 deletions app/gui2/e2e/widgets.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ test('Multi-selection widget', async ({ page }) => {
await actions.goToGraph(page)
await mockMethodCallInfo(page, 'selected', {
methodPointer: {
module: 'Standard.Table.Data.Table',
definedOnType: 'Standard.Table.Data.Table.Table',
module: 'Standard.Table.Table',
definedOnType: 'Standard.Table.Table.Table',
name: 'select_columns',
},
notAppliedArguments: [1],
Expand Down Expand Up @@ -284,8 +284,8 @@ test('Managing aggregates in `aggregate` node', async ({ page }) => {
await actions.goToGraph(page)
await mockMethodCallInfo(page, 'aggregated', {
methodPointer: {
module: 'Standard.Table.Data.Table',
definedOnType: 'Standard.Table.Data.Table.Table',
module: 'Standard.Table.Table',
definedOnType: 'Standard.Table.Table.Table',
name: 'aggregate',
},
notAppliedArguments: [1, 2, 3],
Expand Down Expand Up @@ -317,8 +317,8 @@ test('Managing aggregates in `aggregate` node', async ({ page }) => {
},
{
methodPointer: {
module: 'Standard.Table.Data.Aggregate_Column',
definedOnType: 'Standard.Table.Data.Aggregate_Column.Aggregate_Column',
module: 'Standard.Table.Aggregate_Column',
definedOnType: 'Standard.Table.Aggregate_Column.Aggregate_Column',
name: 'Group_By',
},
notAppliedArguments: [0, 1],
Expand All @@ -343,8 +343,8 @@ test('Managing aggregates in `aggregate` node', async ({ page }) => {
},
{
methodPointer: {
module: 'Standard.Table.Data.Aggregate_Column',
definedOnType: 'Standard.Table.Data.Aggregate_Column.Aggregate_Column',
module: 'Standard.Table.Aggregate_Column',
definedOnType: 'Standard.Table.Aggregate_Column.Aggregate_Column',
name: 'Count_Distinct',
},
notAppliedArguments: [0, 1, 2],
Expand Down Expand Up @@ -381,8 +381,8 @@ test('Managing aggregates in `aggregate` node', async ({ page }) => {
},
{
methodPointer: {
module: 'Standard.Table.Data.Aggregate_Column',
definedOnType: 'Standard.Table.Data.Aggregate_Column.Aggregate_Column',
module: 'Standard.Table.Aggregate_Column',
definedOnType: 'Standard.Table.Aggregate_Column.Aggregate_Column',
name: 'Group_By',
},
notAppliedArguments: [0, 1],
Expand Down
6 changes: 3 additions & 3 deletions app/gui2/mock/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ const mockVizData: Record<string, Uint8Array | ((params: string[]) => Uint8Array
{
type: 'Choice',
constructor: 'Option',
value: 'Standard.Table.Data.Aggregate_Column.Aggregate_Column.Group_By',
value: 'Standard.Table.Aggregate_Column.Aggregate_Column.Group_By',
label: null,
parameters: [
[
Expand Down Expand Up @@ -271,14 +271,14 @@ const mockVizData: Record<string, Uint8Array | ((params: string[]) => Uint8Array
{
type: 'Choice',
constructor: 'Option',
value: 'Standard.Table.Data.Aggregate_Column.Aggregate_Column.Count',
value: 'Standard.Table.Aggregate_Column.Aggregate_Column.Count',
label: null,
parameters: [],
},
{
type: 'Choice',
constructor: 'Option',
value: 'Standard.Table.Data.Aggregate_Column.Aggregate_Column.Count_Distinct',
value: 'Standard.Table.Aggregate_Column.Aggregate_Column.Count_Distinct',
label: null,
parameters: [
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ test.each([
[makeModuleMethod('Standard.Base.Data.read'), 'Data.read'],
[makeStaticMethod('Standard.Base.Data.Vector.new'), 'Vector.new'],
[makeMethod('Standard.Base.Data.Vector.get'), 'get'],
[makeConstructor('Standard.Table.Data.Join_Kind.Join_Kind.LeftInner'), 'Join_Kind.LeftInner'],
[makeModule('Standard.Table.Data.Join_Kind'), 'Join_Kind'],
[makeModule('Standard.Table.Data'), 'Data', 'Standard.Table.Data'],
[makeConstructor('Standard.Table.Join_Kind.Join_Kind.Inner'), 'Join_Kind.Inner'],
[makeModule('Standard.Table.Excel.Excel_Range'), 'Excel_Range'],
[makeModule('Standard.Table.Conversions'), 'Conversions', 'Standard.Table.Conversions'],
[makeModuleMethod('local.Project.main'), 'Project.main'],
])("$name Component's label is valid", (suggestion, expected, mainExpected?) => {
const mainView = new Filtering({})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
export const name = 'Geo Map'
export const icon = 'compass'
export const inputType = 'Standard.Table.Data.Table.Table'
export const inputType = 'Standard.Table.Table.Table'
export const defaultPreprocessor = [
'Standard.Visualization.Geo_Map',
'process_to_json_text',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
export const name = 'Heatmap'
export const icon = 'heatmap'
export const inputType = 'Standard.Table.Data.Table.Table | Standard.Base.Data.Vector.Vector'
export const inputType = 'Standard.Table.Table.Table | Standard.Base.Data.Vector.Vector'
export const defaultPreprocessor = [
'Standard.Visualization.Table.Visualization',
'prepare_visualization',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { computed, ref, watch, watchEffect, watchPostEffect } from 'vue'
export const name = 'Histogram'
export const inputType =
'Standard.Table.Data.Table.Table | Standard.Base.Data.Vector.Vector | Standard.Image.Histogram.Histogram'
'Standard.Table.Table.Table | Standard.Base.Data.Vector.Vector | Standard.Image.Histogram.Histogram'
export const defaultPreprocessor = [
'Standard.Visualization.Histogram',
'process_to_json_text',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { computed, ref, watch, watchEffect, watchPostEffect } from 'vue'
export const name = 'Scatter Plot'
export const icon = 'points'
export const inputType = 'Standard.Table.Data.Table.Table | Standard.Base.Data.Vector.Vector'
export const inputType = 'Standard.Table.Table.Table | Standard.Base.Data.Vector.Vector'
const DEFAULT_LIMIT = 1024
export const defaultPreprocessor = [
'Standard.Visualization.Scatter_Plot',
Expand Down
16 changes: 13 additions & 3 deletions app/gui2/src/components/visualizations/TableVisualization.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
export const name = 'Table'
export const icon = 'table'
export const inputType =
'Standard.Table.Data.Table.Table | Standard.Table.Data.Column.Column | Standard.Table.Data.Row.Row |Standard.Base.Data.Vector.Vector | Standard.Base.Data.Array.Array | Standard.Base.Data.Map.Map | Any'
'Standard.Table.Table.Table | Standard.Table.Column.Column | Standard.Table.Row.Row | Standard.Base.Data.Vector.Vector | Standard.Base.Data.Array.Array | Standard.Base.Data.Map.Map | Any'
export const defaultPreprocessor = [
'Standard.Visualization.Table.Visualization',
'prepare_visualization',
Expand Down Expand Up @@ -236,7 +236,17 @@ function toRender(content: unknown) {
}
watchEffect(() => {
const data_ = props.data
// If the user switches from one visualization type to another, we can receive the raw object.
const data_ =
typeof props.data === 'object' ?
props.data
: {
type: typeof props.data,
json: props.data,
all_rows_count: 1,
data: undefined,
indices: undefined,
}
const options = agGridOptions.value
if (options.api == null) {
return
Expand Down Expand Up @@ -288,7 +298,7 @@ watchEffect(() => {
} else if (Array.isArray(data_.json)) {
columnDefs = [indexField(), toField('Value')]
rowData = data_.json.map((row, i) => ({ [INDEX_FIELD_NAME]: i, Value: toRender(row) }))
isTruncated.value = data_.all_rows_count !== data_.json.length
isTruncated.value = data_.all_rows_count ? data_.all_rows_count !== data_.json.length : false
} else if (data_.json !== undefined) {
columnDefs = [toField('Value')]
rowData = [{ Value: toRender(data_.json) }]
Expand Down
44 changes: 22 additions & 22 deletions app/gui2/stories/mockSuggestions.json
Original file line number Diff line number Diff line change
Expand Up @@ -1023,13 +1023,13 @@
},
{
"type": "module",
"module": "Standard.Table.Data.Table",
"module": "Standard.Table.Excel.Excel_Range",
"documentation": null,
"reexport": "Standard.Table.Data"
"reexport": "Standard.Table.Excel "
},
{
"type": "type",
"module": "Standard.Table.Data.Table",
"module": "Standard.Table.Table",
"name": "Table",
"params": [],
"parentType": "Standard.Base.Any.Any",
Expand All @@ -1038,31 +1038,31 @@
},
{
"type": "method",
"module": "Standard.Table.Data.Table",
"module": "Standard.Table.Table",
"name": "new",
"arguments": [],
"selfType": "Standard.Table.Data.Table.Table",
"returnType": "Standard.Table.Data.Table.Table",
"selfType": "Standard.Table.Table.Table",
"returnType": "Standard.Table.Table.Table",
"isStatic": true,
"documentation": "",
"annotations": []
},
{
"type": "method",
"module": "Standard.Table.Data.Table",
"module": "Standard.Table.Table",
"name": "aggregate",
"arguments": [
{
"name": "self",
"reprType": "Standard.Table.Data.Table.Table",
"reprType": "Standard.Table.Table.Table",
"isSuspended": false,
"hasDefault": false,
"defaultValue": null,
"tagValues": null
},
{
"name": "columns",
"reprType": "Standard.Base.Data.Vector.Vector Standard.Table.Data.Aggregate_Column.Aggregate_Column",
"reprType": "Standard.Base.Data.Vector.Vector Standard.Table.Aggregate_Column.Aggregate_Column",
"isSuspended": false,
"hasDefault": false,
"defaultValue": null,
Expand Down Expand Up @@ -1092,21 +1092,21 @@
]
}
],
"selfType": "Standard.Table.Data.Table.Table",
"selfType": "Standard.Table.Table.Table",
"returnType": "Standard.Base.Any.Any",
"isStatic": false,
"documentation": " ALIAS group by, summarize\nGROUP Standard.Base.Calculations\nICON sigma\n\nAggregates the rows in a table using any `Group_By` entries in columns.\nThe columns argument specifies which additional aggregations to perform and to return.\n\nArguments:\n- columns: Vector of `Aggregate_Column` specifying the aggregated table.\n Expressions can be used within the aggregate column to perform more\n complicated calculations.\n- error_on_missing_columns: Specifies if a missing columns in aggregates\n should result in an error regardless of the `on_problems` settings.\n Defaults to `False`, meaning that problematic aggregate will not be\n included in the result and the problem reported according to the\n `on_problems` setting.\n- on_problems: Specifies how to handle problems if they occur, reporting\n them as warnings by default.\n\n! Error Conditions\n\n - If there are no columns in the output table, a `No_Output_Columns` is\n raised as an error regardless of the problem behavior, because it is\n not possible to create a table without any columns.\n - If a column index is out of range, a `Missing_Input_Columns` is\n reported according to the `on_problems` setting, unless\n `error_on_missing_columns` is set to `True`, in which case it is\n raised as an error. Problems resolving `Group_By` columns are\n reported as dataflow errors regardless of these settings, as a\n missing grouping will completely change semantics of the query.\n - If a column selector is given as a `Text` and it does not match any\n columns in the input table nor is it a valid expression, an\n `Invalid_Aggregate_Column` problem is raised according to the\n `on_problems` settings (unless `error_on_missing_columns` is set to\n `True` in which case it will always be an error). Problems resolving\n `Group_By` columns are reported as dataflow errors regardless of\n these settings, as a missing grouping will completely change\n semantics of the query.\n - If an aggregation fails, an `Invalid_Aggregation` dataflow error is\n raised.\n - Additionally, the following problems may be reported according to the\n `on_problems` setting:\n - If there are invalid column names in the output table,\n a `Invalid_Column_Names`.\n - If there are duplicate column names in the output table,\n a `Duplicate_Output_Column_Names`.\n - If grouping on or computing the `Mode` on a floating point number,\n a `Floating_Point_Equality`.\n - If when concatenating values there is an quoted delimited,\n an `Unquoted_Delimiter`\n - If there are more than 10 issues with a single column,\n an `Additional_Warnings`.\n\n> Example\n Group by the Key column, count the rows\n\n table.aggregate [Aggregate_Column.Group_By \"Key\", Aggregate_Column.Count]",
"annotations": ["columns"]
},
{
"type": "module",
"module": "Standard.Table.Data.Aggregate_Column",
"module": "Standard.Table.Aggregate_Column",
"documentation": null,
"reexport": "Standard.Table.Data"
"reexport": "Standard.Table"
},
{
"type": "type",
"module": "Standard.Table.Data.Aggregate_Column",
"module": "Standard.Table.Aggregate_Column",
"name": "Aggregate_Column",
"params": [],
"parentType": "Standard.Base.Any.Any",
Expand All @@ -1115,7 +1115,7 @@
},
{
"type": "constructor",
"module": "Standard.Table.Data.Aggregate_Column",
"module": "Standard.Table.Aggregate_Column",
"name": "Group_By",
"arguments": [
{
Expand All @@ -1135,13 +1135,13 @@
"tagValues": null
}
],
"returnType": "Standard.Table.Data.Aggregate_Column.Aggregate_Column",
"returnType": "Standard.Table.Aggregate_Column.Aggregate_Column",
"documentation": " Specifies a column to group the rows by.\n\nArguments:\n- column: the column (specified by name, expression or index) to group\n by.\n- new_name: name of new column.",
"annotations": []
},
{
"type": "constructor",
"module": "Standard.Table.Data.Aggregate_Column",
"module": "Standard.Table.Aggregate_Column",
"name": "Count",
"arguments": [
{
Expand All @@ -1153,13 +1153,13 @@
"tagValues": null
}
],
"returnType": "Standard.Table.Data.Aggregate_Column.Aggregate_Column",
"returnType": "Standard.Table.Aggregate_Column.Aggregate_Column",
"documentation": " Creates a new column with the row count of each group. If no rows,\nevaluates to 0.\n\nArguments:\n- new_name: name of new column.",
"annotations": []
},
{
"type": "constructor",
"module": "Standard.Table.Data.Aggregate_Column",
"module": "Standard.Table.Aggregate_Column",
"name": "Count_Distinct",
"arguments": [
{
Expand Down Expand Up @@ -1190,18 +1190,18 @@
]
}
],
"returnType": "Standard.Table.Data.Aggregate_Column.Aggregate_Column",
"returnType": "Standard.Table.Aggregate_Column.Aggregate_Column",
"documentation": " Creates a new column with the count of unique items in the selected\ncolumn(s) within each group. If no rows, evaluates to 0.\n\nArguments:\n- columns: either a single or set of columns (specified by name or\n index) to count across. The aggregation may also be computed over\n an expression evaluated on the Table, if provided instead of a\n single column name. Currently expressions are not supported with\n multiple selection.\n- new_name: name of new column.\n- ignore_nothing: if all values are Nothing won't be included.",
"annotations": []
},
{
"type": "method",
"module": "Standard.Table.Data.Table",
"module": "Standard.Table.Table",
"name": "select_columns",
"arguments": [
{
"name": "self",
"reprType": "Standard.Table.Data.Table.Table",
"reprType": "Standard.Table.Table.Table",
"isSuspended": false,
"hasDefault": false,
"defaultValue": null,
Expand All @@ -1216,7 +1216,7 @@
"tagValues": []
}
],
"selfType": "Standard.Table.Data.Table.Table",
"selfType": "Standard.Table.Table.Table",
"returnType": "Standard.Base.Any.Any",
"isStatic": false,
"documentation": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -431,5 +431,5 @@ get_download_url_for_file file:Enso_File -> Text =
presigned_url

## PRIVATE
asset_uri : Text
asset_uri : Enso_File -> Text
asset_uri file:Enso_File = Utils.assets_api + "/" + file.id
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from Standard.Base import all

import Standard.Table.Data.Type.Value_Type.Value_Type
from Standard.Table import Value_Type

import project.Column_Constraint.Column_Constraint

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ import Standard.Base.Runtime.Ref.Ref
from Standard.Base.Metadata.Choice import Option
from Standard.Base.Metadata.Widget import Single_Choice, Vector_Editor

import Standard.Table.Data.Table.Table
import Standard.Table.Data.Type.Value_Type.Value_Type
import Standard.Table.Internal.Column_Naming_Helper.Column_Naming_Helper
from Standard.Table import Table, Value_Type

import project.Column_Description.Column_Description
import project.DB_Table as DB_Table_Module
Expand Down
12 changes: 4 additions & 8 deletions distribution/lib/Standard/Database/0.0.0-dev/src/DB_Column.enso
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,14 @@ import Standard.Base.Errors.Illegal_State.Illegal_State
import Standard.Base.Internal.Rounding_Helpers
from Standard.Base.Widget_Helpers import make_format_chooser, make_regex_text_widget

import Standard.Table.Data.Column.Column
import Standard.Table.Data.Constants.Previous_Value
import Standard.Table.Data.Table.Table
import Standard.Table.Data.Type.Enso_Types
import Standard.Table.Data.Type.Value_Type_Helpers
import Standard.Table.Internal.Column_Naming_Helper.Column_Naming_Helper
import Standard.Table.Internal.Date_Time_Helpers
import Standard.Table.Internal.Java_Problems
import Standard.Table.Internal.Problem_Builder.Problem_Builder
import Standard.Table.Internal.Value_Type_Helpers
import Standard.Table.Internal.Widget_Helpers
from Standard.Table import Auto, Data_Formatter, Sort_Column, Value_Type
from Standard.Table.Data.Column import default_date_period
from Standard.Table import Auto, Column, Data_Formatter, Previous_Value, Sort_Column, Table, Value_Type
from Standard.Table.Column import default_date_period
from Standard.Table.Errors import Conversion_Failure, Floating_Point_Equality, Inexact_Type_Coercion, Invalid_Value_Type
from Standard.Table.Internal.Cast_Helpers import check_cast_compatibility

Expand Down Expand Up @@ -1187,7 +1183,7 @@ type DB_Column
sort self order=Sort_Direction.Ascending =
self.to_table.order_by [Sort_Column.Index 0 order] . at 0

## ALIAS first, last, sample, slice, top, head, tail, limit
## ALIAS first, head, last, limit, sample, slice, tail, top
GROUP Standard.Base.Selections
ICON select_row
Creates a new Column with the specified range of rows from the input
Expand Down
Loading

0 comments on commit e262801

Please sign in to comment.