Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Handling large integers #202

Merged
merged 4 commits into from
Jul 30, 2021
Merged

Handling large integers #202

merged 4 commits into from
Jul 30, 2021

Conversation

pmahindrakar-oss
Copy link
Contributor

@pmahindrakar-oss pmahindrakar-oss commented Jul 28, 2021

Signed-off-by: Prafulla Mahindrakar [email protected]

TL;DR

Parsing large integers breaks in flytectl since by default json unmarshal converts the number to float64 representation
and when fmt.Sprinf is done for such a value then by default for large floats it uses exponential representation which breaks the parsing
when it tries to do this strconv.ParseInt("8.888888e+06")

Error: failed to parse integer value: strconv.ParseInt: parsing "8.888888e+06": invalid syntax

The fix is to check for the type of float64 and compare the truncated integer portion with the actual float64 value and if they are equal then use %.0f formatter to remove the decimal part in the string.

Test with integer within bounds

cat lp.yaml 
iamRoleARN: ""
inputs:
  am: false
  day_of_week: 2
  number: 88888888
kubeServiceAcct: ""
targetDomain: ""
targetProject: ""
version: v1
workflow: core.flyte_basics.lp.go_greet

 flytectl create execution -p flytesnacks -d development --execFile lp.yaml
execution identifier project:"flytesnacks" domain:"development" name:"f586641988abb438294e" 

Test with integer out of bounds

cat lp.yaml
iamRoleARN: ""
inputs:
  am: false
  day_of_week: 2
  number: 88888888888888888888
kubeServiceAcct: ""
targetDomain: ""
targetProject: ""
version: v1
workflow: core.flyte_basics.lp.go_greet

flytectl create execution -p flytesnacks -d development --execFile lp.yaml
Error: failed to parse integer value: strconv.ParseInt: parsing "88888888888888885248": value out of range

Type

  • Bug Fix
  • Feature
  • Plugin

Are all requirements met?

  • Code completed
  • Smoke tested
  • Unit tests added
  • Code documentation added
  • Any pending items have an associated Issue

Complete description

How did you fix the bug, make the feature etc. Link to any design docs etc

Tracking Issue

flyteorg/flyte#1282

Follow-up issue

NA

Signed-off-by: Prafulla Mahindrakar <[email protected]>
@pmahindrakar-oss pmahindrakar-oss force-pushed the pmahindrakar/fix-parsing branch from cae4a60 to 22cd305 Compare July 28, 2021 11:08
Signed-off-by: Prafulla Mahindrakar <[email protected]>
Signed-off-by: Prafulla Mahindrakar <[email protected]>
katrogan
katrogan previously approved these changes Jul 28, 2021
Signed-off-by: Prafulla Mahindrakar <[email protected]>
@pmahindrakar-oss pmahindrakar-oss merged commit 32129a0 into master Jul 30, 2021
@pmahindrakar-oss pmahindrakar-oss deleted the pmahindrakar/fix-parsing branch July 30, 2021 03:55
eapolinario pushed a commit that referenced this pull request Sep 8, 2023
* Handling large integers

Signed-off-by: Prafulla Mahindrakar <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants