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)
- Status of testing of Apache Airflow 2.9.3rc1 HOT 12
- Using the @task.external_python() to call a task in a venv fails due to attempting to import airflow and other packages not in the external venv HOT 2
- Exception when using session object in CustomPriorityWeightPlugin
- Dependent DAG Based schedules HOT 3
- soft_fail | operator is skipped in all cases and not only "data" related fail HOT 11
- DatabricksRunNowOperator failing as named parameters Jinja templating not getting resolved HOT 10
- AWS SNS Sensor HOT 3
- OpenLineage: Add AirflowRunFacet to DAG run events HOT 1
- Support named mapping for task group HOT 10
- Remove StatsD and replace it with Open Telemetry as first-class citizen HOT 10
- Setting podAnnotations for workers also adds them to other deployments such as scheduler HOT 7
- Hardcoded zooKeeperNamespace in URL doesn't allow to use custom name for zooKeeperNamespace HOT 8
- CDXGen latest caues error when generating SBOM HOT 6
- Add links to example dags in use params section HOT 3
- Airflow Doesn't Register Changes to Codebase or Connections HOT 1
- List Tasks API Call Fails When Airflow DAG is Missing `start_date` param HOT 5
- Adding BigQuery job state before Marking the state as success in Airflow HOT 1
- Add a check in BigQueryInsertJobOperator to verify the Job state before marking it as success in Airflow HOT 2
- Support DEBUG logging by component HOT 1
- Task with "wait_for_downstream" doesn't wait, because start_date is mishandled HOT 6
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.