Skip to content

Commit

Permalink
rename database Table to DB_Table (#9067)
Browse files Browse the repository at this point in the history
Rename database.Table to database.DB_Table to avoid name collisions as part of #8981
  • Loading branch information
AdRiley authored Feb 19, 2024
1 parent ee66b9f commit 27ec236
Show file tree
Hide file tree
Showing 26 changed files with 131 additions and 133 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,8 @@ loadScript('https://cdnjs.cloudflare.com/ajax/libs/sql-formatter/4.0.2/sql-forma
* interpolated query parameters.
*/
class SqlVisualization extends Visualization {
// TODO Change the type below once #837 is done:
// 'Standard.Database.Data.Table.Table | Standard.Database.Data.DB_Column.DB_Column'
static inputType =
'Standard.Database.Data.Table.Table | Standard.Database.Data.DB_Column.DB_Column'
'Standard.Database.Data.DB_Table.DB_Table | Standard.Database.Data.DB_Column.DB_Column'
static label = 'SQL Query'

constructor(api) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
export const name = 'SQL Query'
export const icon = 'braces'
export const inputType =
'Standard.Database.Data.Table.Table | Standard.Database.Data.DB_Column.DB_Column'
'Standard.Database.Data.DB_Table.DB_Table | Standard.Database.Data.DB_Column.DB_Column'
export const defaultPreprocessor = [
'Standard.Visualization.SQL.Visualization',
'prepare_visualization',
Expand Down
4 changes: 2 additions & 2 deletions app/gui2/src/stores/graph/imports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ if (import.meta.vitest) {
const db = new SuggestionDb()
const reexportedModule = makeModule('Standard.AWS.Connections')
reexportedModule.reexportedIn = unwrap(tryQualifiedName('Standard.Base'))
const reexportedType = makeModule('Standard.Database.Table.Table')
const reexportedType = makeModule('Standard.Database.DB_Table.DB_Table')
reexportedType.reexportedIn = unwrap(tryQualifiedName('Standard.Base'))
const extensionMethod = makeMethod('Standard.Network.URI.fetch')
extensionMethod.definedIn = unwrap(tryQualifiedName('Standard.Base'))
Expand Down Expand Up @@ -508,7 +508,7 @@ if (import.meta.vitest) {
{
kind: 'Unqualified',
from: unwrap(tryQualifiedName('Standard.Base')),
import: unwrap(tryIdentifier('Table')),
import: unwrap(tryIdentifier('DB_Table')),
},
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import Standard.Database.Data.DB_Column.DB_Column
import Standard.Database.Data.Dialect
import Standard.Database.Data.SQL_Statement.SQL_Statement
import Standard.Database.Data.SQL_Type.SQL_Type
import Standard.Database.Data.Table.Table
import Standard.Database.Internal.Base_Generator
import Standard.Database.Internal.Column_Fetcher as Column_Fetcher_Module
import Standard.Database.Internal.Column_Fetcher.Column_Fetcher
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import project.Data.Dialect.Dialect
import project.Data.SQL_Query.SQL_Query
import project.Data.SQL_Statement.SQL_Statement
import project.Data.SQL_Type.SQL_Type
import project.Data.Table as Database_Table_Module
import project.Data.Table.Table as Database_Table
import project.Data.DB_Table as Database_Table_Module
import project.Data.DB_Table.DB_Table as Database_Table
import project.Internal.Connection.Entity_Naming_Properties.Entity_Naming_Properties
import project.Internal.Hidden_Table_Registry
import project.Internal.IR.Context.Context
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ from Standard.Base.Widget_Helpers import make_format_chooser, make_regex_text_wi

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
Expand All @@ -22,7 +23,7 @@ from Standard.Table.Internal.Cast_Helpers import check_cast_compatibility
import project.Connection.Connection.Connection
import project.Data.SQL_Statement.SQL_Statement
import project.Data.SQL_Type.SQL_Type
import project.Data.Table.Table
import project.Data.DB_Table.DB_Table
import project.Internal.Helpers
import project.Internal.IR.Context.Context
import project.Internal.IR.Internal_Column.Internal_Column
Expand Down Expand Up @@ -81,9 +82,9 @@ type DB_Column

## ICON data_input
Converts this column into a single-column table.
to_table : Table
to_table : DB_Table
to_table self =
Table.Value self.name self.connection [self.as_internal] self.context
DB_Table.Value self.name self.connection [self.as_internal] self.context

## ALIAS metadata
GROUP Standard.Base.Metadata
Expand All @@ -92,7 +93,7 @@ type DB_Column
The table behaves like `Table.info` - it lists the column name, the count
of non-null items and the value type.
info : Table
info self = self.to_table.info
info self -> Table = self.to_table.info

## GROUP Standard.Base.Input
ICON data_input
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import project.Connection.Connection.Connection
import project.Data.DB_Column.DB_Column
import project.Data.SQL_Statement.SQL_Statement
import project.Data.SQL_Type.SQL_Type
import project.Data.Table.Table
import project.Data.DB_Table.DB_Table
import project.Internal.Column_Fetcher.Column_Fetcher
import project.Internal.Error_Mapper.Error_Mapper
import project.Internal.IR.Context.Context
Expand Down Expand Up @@ -65,7 +65,7 @@ type Dialect

## PRIVATE
Prepares a distinct operation.
prepare_distinct : Table -> Vector -> Case_Sensitivity -> Problem_Builder -> Table
prepare_distinct : DB_Table -> Vector -> Case_Sensitivity -> Problem_Builder -> DB_Table
prepare_distinct self table key_columns case_sensitivity problem_builder =
_ = [table, key_columns, case_sensitivity, problem_builder]
Unimplemented.throw "This is an interface only."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ from Standard.Base.Data.Index_Sub_Range import normalize_ranges, resolve_ranges,

from Standard.Table import Set_Mode

import project.Data.Table.Table
import project.Data.DB_Table.DB_Table
from project.Errors import Unsupported_Database_Operation

## PRIVATE
Expand All @@ -21,7 +21,7 @@ type Take_Drop

## PRIVATE
Apply `take` or `drop` to a table, returning the specified by the selector.
take_drop_helper : Take_Drop -> Table -> (Index_Sub_Range | Range | Integer) -> Table
take_drop_helper : Take_Drop -> DB_Table -> (Index_Sub_Range | Range | Integer) -> DB_Table
take_drop_helper take_drop table selector =
check_supported selector <|
length = table.row_count
Expand Down Expand Up @@ -74,7 +74,7 @@ cleanup_ranges ranges:(Vector Range) =

## PRIVATE
Filter a table with a single range. Returns only those rows whose row column fall within the range.
generate_subquery : Table -> Text -> Range -> Table
generate_subquery : DB_Table -> Text -> Range -> DB_Table
generate_subquery table row_column_name range =
case range.step of
1 ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Standard.Table.Internal.Widget_Helpers
from Standard.Table.Errors import all

import project.Connection.Connection.Connection
import project.Data.Table.Table
import project.Data.DB_Table.DB_Table
import project.Data.Update_Action.Update_Action
from project.Errors import all
from project.Internal.Upload_Table import all
Expand Down Expand Up @@ -56,8 +56,8 @@ from project.Internal.Upload_Table import all
More expensive checks, like clashing keys are checked only on the sample of
rows, so errors may still occur when the output action is enabled.
@primary_key Widget_Helpers.make_column_name_vector_selector
Table.select_into_database_table : Connection -> Text -> Vector Text | Nothing -> Boolean -> Problem_Behavior -> Table ! Table_Already_Exists | Inexact_Type_Coercion | Missing_Input_Columns | Non_Unique_Key | SQL_Error | Illegal_Argument
Table.select_into_database_table self connection (table_name : Text) primary_key=[self.columns.first.name] temporary=False on_problems=Problem_Behavior.Report_Warning =
DB_Table.select_into_database_table : Connection -> Text -> Vector Text | Nothing -> Boolean -> Problem_Behavior -> DB_Table ! Table_Already_Exists | Inexact_Type_Coercion | Missing_Input_Columns | Non_Unique_Key | SQL_Error | Illegal_Argument
DB_Table.select_into_database_table self connection (table_name : Text) primary_key=[self.columns.first.name] temporary=False on_problems=Problem_Behavior.Report_Warning =
select_into_table_implementation self connection table_name primary_key temporary on_problems

## GROUP Standard.Base.Output
Expand Down Expand Up @@ -131,8 +131,8 @@ Table.select_into_database_table self connection (table_name : Text) primary_key
More expensive checks, like clashing keys or unmatched rows are checked
only on a sample of rows, so errors may still occur when the output action
is enabled.
Table.update_rows : Table | In_Memory_Table -> Update_Action -> Vector Text | Nothing -> Boolean -> Problem_Behavior -> Table ! Table_Not_Found | Unmatched_Columns | Missing_Input_Columns | Column_Type_Mismatch | SQL_Error | Illegal_Argument
Table.update_rows self (source_table : Table | In_Memory_Table) (update_action : Update_Action = Update_Action.Update_Or_Insert) (key_columns : Vector | Nothing = default_key_columns self) (error_on_missing_columns : Boolean = False) (on_problems : Problem_Behavior = Problem_Behavior.Report_Warning) =
DB_Table.update_rows : DB_Table | In_Memory_Table -> Update_Action -> Vector Text | Nothing -> Boolean -> Problem_Behavior -> DB_Table ! Table_Not_Found | Unmatched_Columns | Missing_Input_Columns | Column_Type_Mismatch | SQL_Error | Illegal_Argument
DB_Table.update_rows self (source_table : DB_Table | In_Memory_Table) (update_action : Update_Action = Update_Action.Update_Or_Insert) (key_columns : Vector | Nothing = default_key_columns self) (error_on_missing_columns : Boolean = False) (on_problems : Problem_Behavior = Problem_Behavior.Report_Warning) =
common_update_table source_table self update_action key_columns error_on_missing_columns on_problems

## GROUP Standard.Base.Output
Expand Down Expand Up @@ -191,6 +191,6 @@ Table.update_rows self (source_table : Table | In_Memory_Table) (update_action :
columns, and returns the count of rows that would have been deleted by this
operation, with a `Dry_Run_Operation` warning attached.
@key_columns Widget_Helpers.make_column_name_vector_selector
Table.delete_rows : Table | In_Memory_Table -> Vector Text | Nothing -> Boolean -> Integer ! Missing_Input_Columns | SQL_Error
Table.delete_rows self (key_values_to_delete : Table | In_Memory_Table) (key_columns : Vector Text | Nothing = default_key_columns_required self) (allow_duplicate_matches : Boolean = False) =
DB_Table.delete_rows : DB_Table | In_Memory_Table -> Vector Text | Nothing -> Boolean -> Integer ! Missing_Input_Columns | SQL_Error
DB_Table.delete_rows self (key_values_to_delete : DB_Table | In_Memory_Table) (key_columns : Vector Text | Nothing = default_key_columns_required self) (allow_duplicate_matches : Boolean = False) =
common_delete_rows self key_values_to_delete key_columns allow_duplicate_matches
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Standard.Table.Internal.Widget_Helpers
from Standard.Table.Errors import all

import project.Connection.Connection.Connection
import project.Data.Table.Table as Database_Table
import project.Data.DB_Table.DB_Table as Database_Table
import project.Data.Update_Action.Update_Action
from project.Errors import all
from project.Internal.Upload_Table import all
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ from Standard.Table.Data.Aggregate_Column.Aggregate_Column import all
from Standard.Table.Errors import Floating_Point_Equality

import project.Data.Dialect.Dialect
import project.Data.Table.Table
import project.Data.DB_Table.DB_Table
import project.Internal.IR.Internal_Column.Internal_Column
import project.Internal.IR.SQL_Expression.SQL_Expression
import project.Internal.SQL_Type_Reference.SQL_Type_Reference
Expand All @@ -25,7 +25,7 @@ from project.Errors import Unsupported_Database_Operation
operation, list of input columns and a raw SQL IR Expression) and returns
the inferred type for the aggregation.
- problem_builder: A `Problem_Builder` instance used for reporting warnings.
make_aggregate_column : Table -> Aggregate_Column -> Text -> Dialect -> (Any -> Any -> Any -> SQL_Type_Reference) -> Problem_Builder -> SQL_Expression
make_aggregate_column : DB_Table -> Aggregate_Column -> Text -> Dialect -> (Any -> Any -> Any -> SQL_Type_Reference) -> Problem_Builder -> SQL_Expression
make_aggregate_column table aggregate new_name dialect infer_return_type problem_builder =
is_non_empty_selector v = v.is_nothing.not && v.not_empty
simple_aggregate op_kind columns =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ from Standard.Table.Errors import Floating_Point_Equality

import project.Connection.Connection.Connection
import project.Data.SQL_Type.SQL_Type
import project.Data.Table.Table
import project.Data.DB_Table.DB_Table
import project.Internal.Helpers
import project.Internal.IR.Context.Context
import project.Internal.IR.From_Spec.From_Spec
Expand Down Expand Up @@ -77,7 +77,7 @@ type Join_Subquery_Setup
[old.name, new]

## PRIVATE
prepare_subqueries : Connection -> Table -> Table -> Boolean -> Boolean -> Pair Join_Subquery_Setup
prepare_subqueries : Connection -> DB_Table -> DB_Table -> Boolean -> Boolean -> Pair Join_Subquery_Setup
prepare_subqueries connection left right needs_left_indicator needs_right_indicator =
table_naming_helper = connection.base_connection.table_naming_helper
column_naming_helper = connection.base_connection.column_naming_helper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Standard.Table.Internal.Lookup_Helpers.Lookup_Column
from Standard.Table import Join_Kind, Value_Type
from Standard.Table.Errors import all

import project.Data.Table.Table
import project.Data.DB_Table.DB_Table
import project.Internal.IR.Context.Context
import project.Internal.IR.From_Spec.From_Spec
import project.Internal.IR.Internal_Column.Internal_Column
Expand All @@ -19,7 +19,7 @@ from project.Internal.Upload_Table import check_for_null_keys
## PRIVATE
Implementation of `lookup_and_replace` for Database backend.
See `Table.lookup_and_replace` for more details.
build_lookup_query : Table -> Table -> (Vector (Integer | Text | Regex) | Text | Integer | Regex) -> Boolean -> Boolean -> Problem_Behavior -> Table ! Missing_Input_Columns | Non_Unique_Key | Unmatched_Rows_In_Lookup
build_lookup_query : DB_Table -> DB_Table -> (Vector (Integer | Text | Regex) | Text | Integer | Regex) -> Boolean -> Boolean -> Problem_Behavior -> DB_Table ! Missing_Input_Columns | Non_Unique_Key | Unmatched_Rows_In_Lookup
build_lookup_query base_table lookup_table key_columns add_new_columns allow_unmatched_rows on_problems =
lookup_columns = Lookup_Helpers.prepare_columns_for_lookup base_table lookup_table key_columns add_new_columns allow_unmatched_rows on_problems
lookup_columns.if_not_error <| check_initial_invariants base_table lookup_table lookup_columns allow_unmatched_rows <|
Expand Down Expand Up @@ -57,12 +57,12 @@ build_lookup_query base_table lookup_table key_columns add_new_columns allow_unm
new_ctx_with_invariant_check = new_ctx.add_where_filters [make_invariant_check subquery_setup.lookup_counter allow_unmatched_rows]

precheck_for_duplicate_matches lookup_columns subquery_setup base_table.connection new_ctx <|
Table.Value subquery_setup.new_table_name base_table.connection new_columns new_ctx_with_invariant_check
DB_Table.Value subquery_setup.new_table_name base_table.connection new_columns new_ctx_with_invariant_check

## PRIVATE
Checks if they key contains NULL values or if there would be unmatched rows
(if `allow_unmatched_rows` is `False`), and reports any errors.
check_initial_invariants : Table -> Table -> Vector Lookup_Column -> Boolean -> Any -> Any
check_initial_invariants : DB_Table -> DB_Table -> Vector Lookup_Column -> Boolean -> Any -> Any
check_initial_invariants base_table lookup_table lookup_columns allow_unmatched_rows ~continuation =
key_column_names = lookup_columns.flat_map c-> case c of
Lookup_Column.Key_Column base_column lookup_column ->
Expand Down Expand Up @@ -192,7 +192,7 @@ precheck_for_duplicate_matches lookup_columns subquery_setup connection new_ctx
key_columns_for_duplicate_check = (_.flatten) <| lookup_columns.map_with_index ix-> c-> case c of
Lookup_Column.Key_Column _ _ -> [subquery_setup.get_self_column ix]
_ -> []
table_for_duplicate_check = Table.Value subquery_setup.new_table_name connection [subquery_setup.lookup_counter]+key_columns_for_duplicate_check new_ctx
table_for_duplicate_check = DB_Table.Value subquery_setup.new_table_name connection [subquery_setup.lookup_counter]+key_columns_for_duplicate_check new_ctx
duplicate_lookup_matches = table_for_duplicate_check.filter 0 (Filter_Condition.Greater than=1) . read max_rows=1 warn_if_more_rows=False
case duplicate_lookup_matches.row_count > 0 of
True ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Standard.Base.Errors.Illegal_Argument.Illegal_Argument
from Standard.Base.Runtime import assert

import project.Data.DB_Column.DB_Column
import project.Data.Table.Table
import project.Data.DB_Table.DB_Table
import project.Internal.IR.Internal_Column.Internal_Column
from project.Errors import Unsupported_Database_Operation

Expand All @@ -20,7 +20,7 @@ polyglot java import java.util.regex.Pattern

To combine different objects they need to satisfy this requirement, otherwise
the combination would be ill-formed.
check_integrity : (Table | DB_Column) -> (Table | DB_Column) -> Boolean
check_integrity : (DB_Table | DB_Column) -> (DB_Table | DB_Column) -> Boolean
check_integrity entity1 entity2 =
ctx = entity1.context == entity2.context
ctx && (check_connection entity1 entity2)
Expand All @@ -32,7 +32,7 @@ check_integrity entity1 entity2 =
Arguments:
- entity1: The entity to check against the second.
- entity2: The entity to check against the first.
check_connection : (Table | DB_Column) -> (Table | DB_Column) -> Boolean
check_connection : (DB_Table | DB_Column) -> (DB_Table | DB_Column) -> Boolean
check_connection entity1 entity2 =
# The `if_not_error` is needed `Meta.is_same_object` does not forward dataflow errors.
entity1.if_not_error <| entity2.if_not_error <|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Standard.Table.Data.Type.Value_Type.Value_Type

import project.Data.SQL_Statement.SQL_Statement
import project.Data.SQL_Type.SQL_Type
import project.Data.Table.Table as Database_Table
import project.Data.DB_Table.DB_Table as Database_Table
import project.Internal.Column_Fetcher as Column_Fetcher_Module
import project.Internal.In_Transaction.In_Transaction
import project.Internal.SQL_Warning_Helper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import project.Data.Dialect
import project.Data.SQL_Query.SQL_Query
import project.Data.SQL_Statement.SQL_Statement
import project.Data.SQL_Type.SQL_Type
import project.Data.Table.Table as Database_Table
import project.Data.DB_Table.DB_Table as Database_Table
import project.Internal.IR.Query.Query
import project.Internal.JDBC_Connection
import project.Internal.Postgres.Postgres_Entity_Naming_Properties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import project.Data.SQL.SQL_Builder
import project.Data.SQL.SQL_Fragment
import project.Data.SQL_Statement.SQL_Statement
import project.Data.SQL_Type.SQL_Type
import project.Data.Table.Table
import project.Data.DB_Table.DB_Table
import project.Internal.Base_Generator
import project.Internal.Column_Fetcher as Column_Fetcher_Module
import project.Internal.Column_Fetcher.Column_Fetcher
Expand Down Expand Up @@ -107,7 +107,7 @@ type Postgres_Dialect

## PRIVATE
Prepares a distinct operation.
prepare_distinct : Table -> Vector -> Case_Sensitivity -> Problem_Builder -> Table
prepare_distinct : DB_Table -> Vector -> Case_Sensitivity -> Problem_Builder -> DB_Table
prepare_distinct self table key_columns case_sensitivity problem_builder =
table_name_deduplicator = table.connection.base_connection.table_naming_helper.create_unique_name_strategy
table_name_deduplicator.mark_used table.name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import project.Data.Dialect
import project.Data.SQL_Query.SQL_Query
import project.Data.SQL_Statement.SQL_Statement
import project.Data.SQL_Type.SQL_Type
import project.Data.Table.Table as Database_Table
import project.Data.DB_Table.DB_Table as Database_Table
import project.Internal.IR.Query.Query
import project.Internal.JDBC_Connection
import project.Internal.SQL_Type_Reference.SQL_Type_Reference
Expand Down
Loading

0 comments on commit 27ec236

Please sign in to comment.