Comments (5)
Thanks for opening your first issue here! Be sure to follow the issue template! If you are willing to raise PR to address this issue please do so, no need to wait for approval.
from airflow.
Json does not make a difference between float and ints. https://www.json.org/json-en.html - this is just number. There is no way you can distinguish the two 18.0 when parsed is just 18 and that's how it is printed. Those two are equivalent and you can't do anything about it.
from airflow.
BTW. If you want to preserve ".0" and it makes a difference for you - you should store it as string and expect string in the value.
from airflow.
>>> import json
>>> json.dumps(18.0)
'18.0'
>>> json.loads(json.dumps(18.0))
18.0
The json module does preserve fractions though. As described earlier, the fraction is stored correctly. It is only converted to int when loaded by the web interface.
BTW. If you want to preserve ".0" and it makes a difference for you - you should store it as string and expect string in the value.
I implemented this already to get my stuff working reliably again :)
Obviously it is JS doing the ugly stuff
> JSON.stringify(18.0)
'18'
from airflow.
What you are referring to is an implementation detail of Python JSON parser - when you are using Python dictionaries / variables you have indeed different types of fields - float and int are different. And the dump method of the parser might choose to add '.0' in this case.
But JSON specification is very clear. Any number that you pass in json is a "number" and JSON specification does not mandate or even hint, whether floating points should be preserved if they are .0. Simply 18.0 and 18 are different representation of the same number and json parser and producer has absolutely no expectation and requirement the .0 will be preserved when serializing/deserializing JSON. So JS does not do ugly stuff. It acts according to the specification. And you should never rely on the fact that .0 is preserved when you go through serialize/deserialize because it's not guaranteed or not even hinted that it should be preserved.
BTW. I am not sure if you are aware but J
in JSON stands for Javascript
because that's where JSON was originally used, so I'd argue that Python implementation diverged from what original JSON implementation did.
from airflow.
Related Issues (20)
- OpenLineage defaults in airflow.cfg incorrect HOT 4
- Add deferrable support to `LambdaInvokeFunctionOperator` HOT 10
- OpenLineage Provider issue: scheduler shuts down after pickle of OpenLineageListener fails HOT 5
- Version 2.9.2 airflow db migrate unsupported queries for mysql HOT 8
- Mismatched Xcom Map Index when Dynamic Mapping over TaskGroup and not all mapped tasks have run
- After deleting a dag from the dags directory, it is still displayed in the UI HOT 3
- Syntax highlight and copy button for entries in XCom tab
- Deferred task behaviour is different from normal task HOT 1
- Request to Reintroduce Tasks Duration Multi Line Graph HOT 1
- The task was stuck, but when marking it as successful, it continues to run the remaining part of the job. HOT 2
- Mark Success but remote task continue running HOT 4
- Add on_kill to SSHOperator HOT 4
- Airflow scheduler crashes with a psycopg2.errors.GroupingError due to an incorrect SQL query when detecting orphaned datasets
- Support extraInitContainers for migrateDatabaseJob HOT 1
- ObjectStoragePath should be template-able HOT 2
- After deleting a dag from the dags directory, it is still displayed in the UI HOT 2
- values.yaml `dags.gitSync.containerLifecycleHooks` Does not working HOT 2
- Improve SFTPOperator with directory transfer and DELETE operation HOT 1
- add ower to TaskInstance class HOT 1
- Status of testing Providers that were prepared on June 22, 2024 HOT 38
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from airflow.