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

[minor] /tableConfigs/validate can't convert default timestamp null value to LONG #12020

Open
dd-willgan opened this issue Nov 17, 2023 · 4 comments
Labels
bug ui UI related issue

Comments

@dd-willgan
Copy link
Contributor

Calling /tableConfigs/validate will convert a timestamp field to the following

"dateTimeFieldSpecs": [
	{
		"format": "1:MILLISECONDS:EPOCH",
		"sampleValue": null,
		"granularity": "1:MILLISECONDS",
		"singleValueField": true,
		"name": "created_at_epoch_ms",
		"maxLength": 512,
		"dataType": "LONG",
		"transformFunction": null,
		"defaultNullValue": -9223372036854775808,
		"virtualColumnProvider": null,
		"defaultNullValueString": "-9223372036854775808"
	}
]

However, if this config is fed to /tableConfigs/validate again, the following error will be thrown

exception: Cannot convert value: \'-9223372036854776000\' to type: LONG
@Jackie-Jiang
Copy link
Contributor

Seems like a problem of JSON precision loss, where -9223372036854775808 is read as double thus converted to -9223372036854776000.
Do you send the exactly same JSON to the validate API?

@dd-willgan
Copy link
Contributor Author

Thanks @Jackie-Jiang that makes sense. The JSON sent to validate API originally is

{
  "format": "1:MILLISECONDS:EPOCH",
  "granularity": "1:MILLISECONDS",
  "name": "created_at_epoch_ms",
  "dataType": "LONG"
}

@Jackie-Jiang
Copy link
Contributor

Did some research and find this as a known issue in Swagger and there is no plan to fix it: swagger-api/swagger-ui#2030
If you use Swagger to query Pinot, the result might also lose precision. If you try with command line you should be able to see the correct values returned

@Jackie-Jiang Jackie-Jiang added the ui UI related issue label Dec 5, 2023
@Jackie-Jiang
Copy link
Contributor

To add more context, then validating this field:

{
  "format": "1:MILLISECONDS:EPOCH",
  "granularity": "1:MILLISECONDS",
  "name": "ts",
  "dataType": "LONG"
}

Swagger will show the response as:

{
  "format": "1:MILLISECONDS:EPOCH",
  "granularity": "1:MILLISECONDS",
  "sampleValue": null,
  "singleValueField": true,
  "notNull": false,
  "dataType": "LONG",
  "maxLength": 512,
  "virtualColumnProvider": null,
  "defaultNullValue": -9223372036854776000,
  "defaultNullValueString": "-9223372036854775808",
  "transformFunction": null,
  "name": "ts"
}

Note that the precision loss already happens here.

I tried using the following json as input and it works without throwing exception, but of course the response still lose precision:

{
  "format": "1:MILLISECONDS:EPOCH",
  "granularity": "1:MILLISECONDS",
  "dataType": "LONG",
  "defaultNullValue": -9223372036854775808
  "name": "ts"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug ui UI related issue
Projects
None yet
Development

No branches or pull requests

2 participants