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

JSAPI returns undefined for a null value in table data #5400

Closed
vbabich opened this issue Apr 23, 2024 · 3 comments · Fixed by #5437
Closed

JSAPI returns undefined for a null value in table data #5400

vbabich opened this issue Apr 23, 2024 · 3 comments · Fixed by #5437
Assignees
Labels
bug Something isn't working core Core development tasks jsapi
Milestone

Comments

@vbabich
Copy link
Contributor

vbabich commented Apr 23, 2024

Description

The value retrieved from a table via the JSAPI doesn't match the value shown in the console.

Steps to reproduce

  • On a DHE VM, run this snippet in a Core+ groovy console:
ts = emptyTable(1).update("X=(String)null")
println ts.getColumnSource("X").get(0)
// Prints "null"
  • Create a Core+ Groovy PQ with the snippet above, save it as TestPQ
  • Open https://<vm>/irisapi/table_viewport.html
  • Run this snippet in the browser console:
var { default: getObject } = await import('./get_object.js')
async function getValue(queryName, tableName, colName, rowIndex) {
    var q = c.getKnownConfigs().find(q => q.name === queryName)
    var t = await getObject(c, q, tableName)
    console.log('size:', t.size)
    t.setViewport(rowIndex, rowIndex)
    var v = await t.getViewportData()
    var column = t.findColumn(colName)
    console.log('viewport, column:', v, column)
    return v.rows[0].get(column);
}
var value = await getValue('TestPQ', 'ts', 'X', 0)
console.log('value, type:', value, typeof value)
// Prints "value, type: undefined undefined"

Expected results

Value retrieved via JSAPI matches the value returned by ts.getColumnSource("X").get(0) in the Code Studio

Actual results

JSAPI returns undefined when the actual value in the table is null

Versions

  • Core+: 0.33.3
@vbabich vbabich added bug Something isn't working triage labels Apr 23, 2024
@rcaudy rcaudy added jsapi core Core development tasks and removed triage labels Apr 23, 2024
@rcaudy rcaudy added this to the 2. April 2024 milestone Apr 23, 2024
@niloc132
Copy link
Member

niloc132 commented Apr 23, 2024

We may categorize this as a "known issue, not planned", this happens in a few places, and always has done so. EDIT: this may not be true, I'll investigate further.

Will investigate briefly as part of #188.

@mofojed
Copy link
Member

mofojed commented Apr 30, 2024

To test in JSAPI page (e.g. from http://localhost:10000/jsapi/table_basic.html), enter this in the browser console:

var dh = (await import('./dh-core.js')).default
var client = new dh.CoreClient(window.location.protocol + "//" + window.location.host);
await client.login({type: 'io.deephaven.authentication.psk.PskAuthenticationHandler', token: 'iris'});
var connection = await client.getAsIdeConnection();
var ide = await connection.startSession("python");
await ide.runCode(`
from deephaven import empty_table

x = empty_table(1).update("X=(String)null")
`)


var x = await connection.getObject({ type: 'Table', name: 'x' })
x.setViewport(0, 0)
var data = await x.getViewportData()
var value = data.get(0).get(x.columns[0])
console.log('Value is', value, ', isNull?=', value === null)

We should expect the value to be null, not undefined.

@niloc132
Copy link
Member

PR up is, tested in plain DHC:

  • edit table_viewport.html to instead run this simple script:
from deephaven import time_table, empty_table
remoteTable = empty_table(1).update("X=(String)null")

When this bug is happening, the result should be undefined - after the fix, the expected result instead is null.

niloc132 added a commit that referenced this issue May 2, 2024
…ata (#5437)

While Java arrays are initialized to nulls, GWT normalizes undefined
and null to be equivalent, so we need to explicitly assign null values
when building arrays.

Adds tests to ensure this doesn't break as part of #188.

Fixes #5400
stanbrub pushed a commit that referenced this issue May 3, 2024
…ata (#5437)

While Java arrays are initialized to nulls, GWT normalizes undefined
and null to be equivalent, so we need to explicitly assign null values
when building arrays.

Adds tests to ensure this doesn't break as part of #188.

Fixes #5400
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working core Core development tasks jsapi
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants