mirror of
https://github.com/enso-org/enso.git
synced 2024-12-23 00:11:45 +03:00
Various fixes to visualizations (#10745)
- Closes #10716 by un-marking the `Snowflake_Connection` as `private`. - Does the same to `SQLServer_Connection`. - Makes sure that `Snowflake_Connection` has correct visualization and enables links for it. - Adds a fallback in `to_default_visualization_data` and in Table's `prepare_visualization` so that if `to_js_object` of a given type is malformed, we still get some kind of visualization + debug info about the underlying error.
This commit is contained in:
parent
057beec373
commit
fc3ac6ced1
@ -106,6 +106,8 @@ const SQLITE_CONNECTIONS_NODE_TYPE =
|
|||||||
'Standard.Database.Internal.SQLite.SQLite_Connection.SQLite_Connection'
|
'Standard.Database.Internal.SQLite.SQLite_Connection.SQLite_Connection'
|
||||||
const POSTGRES_CONNECTIONS_NODE_TYPE =
|
const POSTGRES_CONNECTIONS_NODE_TYPE =
|
||||||
'Standard.Database.Internal.Postgres.Postgres_Connection.Postgres_Connection'
|
'Standard.Database.Internal.Postgres.Postgres_Connection.Postgres_Connection'
|
||||||
|
const SNOWFLAKE_CONNECTIONS_NODE_TYPE =
|
||||||
|
'Standard.Snowflake.Snowflake_Connection.Snowflake_Connection'
|
||||||
|
|
||||||
const rowLimit = ref(0)
|
const rowLimit = ref(0)
|
||||||
const page = ref(0)
|
const page = ref(0)
|
||||||
@ -165,6 +167,7 @@ const newNodeSelectorValues = computed(() => {
|
|||||||
break
|
break
|
||||||
case SQLITE_CONNECTIONS_NODE_TYPE:
|
case SQLITE_CONNECTIONS_NODE_TYPE:
|
||||||
case POSTGRES_CONNECTIONS_NODE_TYPE:
|
case POSTGRES_CONNECTIONS_NODE_TYPE:
|
||||||
|
case SNOWFLAKE_CONNECTIONS_NODE_TYPE:
|
||||||
tooltipValue = 'table'
|
tooltipValue = 'table'
|
||||||
headerName = 'Tables'
|
headerName = 'Tables'
|
||||||
break
|
break
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
private
|
|
||||||
|
|
||||||
from Standard.Base import all
|
from Standard.Base import all
|
||||||
import Standard.Base.Metadata.Display
|
import Standard.Base.Metadata.Display
|
||||||
from Standard.Base.Metadata.Choice import Option
|
from Standard.Base.Metadata.Choice import Option
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
private
|
|
||||||
|
|
||||||
from Standard.Base import all
|
from Standard.Base import all
|
||||||
import Standard.Base.Metadata.Display
|
import Standard.Base.Metadata.Display
|
||||||
from Standard.Base.Metadata.Choice import Option
|
from Standard.Base.Metadata.Choice import Option
|
||||||
@ -314,3 +312,9 @@ type Snowflake_Connection
|
|||||||
on the 'subclasses'.
|
on the 'subclasses'.
|
||||||
base_connection : Connection
|
base_connection : Connection
|
||||||
base_connection self = self.connection
|
base_connection self = self.connection
|
||||||
|
|
||||||
|
## PRIVATE
|
||||||
|
Converts this value to a JSON serializable object.
|
||||||
|
to_js_object : JS_Object
|
||||||
|
to_js_object self =
|
||||||
|
JS_Object.from_pairs [["type", "Snowflake_Connection"], ["links", self.tables.at "Name" . to_vector]]
|
@ -5,7 +5,7 @@ import Standard.Base.Errors.Illegal_State.Illegal_State
|
|||||||
import Standard.Database.Connection.Connection_Options.Connection_Options
|
import Standard.Database.Connection.Connection_Options.Connection_Options
|
||||||
import Standard.Database.Connection.Credentials.Credentials
|
import Standard.Database.Connection.Credentials.Credentials
|
||||||
|
|
||||||
import project.Internal.Snowflake_Connection.Snowflake_Connection
|
import project.Snowflake_Connection.Snowflake_Connection
|
||||||
|
|
||||||
polyglot java import net.snowflake.client.jdbc.SnowflakeDriver
|
polyglot java import net.snowflake.client.jdbc.SnowflakeDriver
|
||||||
|
|
||||||
|
@ -34,7 +34,9 @@ JS_Object.default_visualization self = Id.json
|
|||||||
|
|
||||||
2.to_default_visualization_data
|
2.to_default_visualization_data
|
||||||
Any.to_default_visualization_data : Text
|
Any.to_default_visualization_data : Text
|
||||||
Any.to_default_visualization_data self = self.to_json
|
Any.to_default_visualization_data self =
|
||||||
|
Panic.recover Any self.to_json . catch Any err->
|
||||||
|
(JS_Object.from_pairs [["value", self.to_display_text], ["_to_js_object_error_", err.to_display_text]]).to_json
|
||||||
|
|
||||||
## PRIVATE
|
## PRIVATE
|
||||||
|
|
||||||
|
@ -187,15 +187,23 @@ make_json_for_table dataframe all_rows_count include_index_col =
|
|||||||
Create JSON serialization of values.
|
Create JSON serialization of values.
|
||||||
make_json_for_other : Any -> JS_Object
|
make_json_for_other : Any -> JS_Object
|
||||||
make_json_for_other x =
|
make_json_for_other x =
|
||||||
js_value = x.to_js_object
|
js_value = Panic.recover Any x.to_js_object
|
||||||
value = if js_value.is_a JS_Object . not then js_value else
|
supports_js_object = js_value.is_error.not
|
||||||
pairs = [['_display_text_', x.to_display_text]] + js_value.field_names.map f-> [f, make_json_for_value (js_value.get f)]
|
case supports_js_object of
|
||||||
JS_Object.from_pairs pairs
|
True ->
|
||||||
link_fields = if js_value.is_a JS_Object . not then [] else
|
value = if js_value.is_a JS_Object . not then js_value else
|
||||||
if js_value.contains_key 'links' then [["links", js_value.get 'links']] else []
|
pairs = [['_display_text_', x.to_display_text]] + js_value.field_names.map f-> [f, make_json_for_value (js_value.get f)]
|
||||||
additional_fields = if js_value.is_a JS_Object . not then [] else
|
JS_Object.from_pairs pairs
|
||||||
if js_value.contains_key 'get_child_node' then [["get_child_node", js_value.get 'get_child_node']] else []
|
link_fields = if js_value.is_a JS_Object . not then [] else
|
||||||
JS_Object.from_pairs <| [["json", value]] + additional_fields + link_fields
|
if js_value.contains_key 'links' then [["links", js_value.get 'links']] else []
|
||||||
|
additional_fields = if js_value.is_a JS_Object . not then [] else
|
||||||
|
if js_value.contains_key 'get_child_node' then [["get_child_node", js_value.get 'get_child_node']] else []
|
||||||
|
JS_Object.from_pairs <| [["json", value]] + additional_fields + link_fields
|
||||||
|
|
||||||
|
# Fallback for objects that fail to be serialized through `to_js_object`.
|
||||||
|
False ->
|
||||||
|
json = JS_Object.from_pairs [["_display_text_", x.to_display_text], ["_to_js_object_error_", js_value.catch.to_display_text]]
|
||||||
|
JS_Object.from_pairs [["json", json]]
|
||||||
|
|
||||||
## PRIVATE
|
## PRIVATE
|
||||||
Create JSON serialization of values for the table.
|
Create JSON serialization of values for the table.
|
||||||
|
@ -623,7 +623,7 @@ object ProgramExecutionSupport {
|
|||||||
.getOrElse(expressionValue.getClass)
|
.getOrElse(expressionValue.getClass)
|
||||||
ctx.executionService.getLogger.log(
|
ctx.executionService.getLogger.log(
|
||||||
Level.WARNING,
|
Level.WARNING,
|
||||||
"Execution of visualization [{0}] on value [{1}] of [{2}] failed. {3} | {4}",
|
"Execution of visualization [{0}] on value [{1}] of [{2}] failed. {3} | {4} | {5}",
|
||||||
Array[Object](
|
Array[Object](
|
||||||
visualizationId,
|
visualizationId,
|
||||||
expressionId,
|
expressionId,
|
||||||
|
@ -2806,7 +2806,7 @@ class RuntimeVisualizationsTest extends AnyFlatSpec with Matchers {
|
|||||||
data
|
data
|
||||||
}
|
}
|
||||||
val stringified = new String(data)
|
val stringified = new String(data)
|
||||||
stringified shouldEqual "\"Function\""
|
stringified should include("""{"value":"Function"""")
|
||||||
}
|
}
|
||||||
|
|
||||||
it should "attach text visualization with arguments" in withContext() {
|
it should "attach text visualization with arguments" in withContext() {
|
||||||
|
Loading…
Reference in New Issue
Block a user