Skip to content

Commit

Permalink
fix: renamed precision parameter to decimal in docs
Browse files Browse the repository at this point in the history
  • Loading branch information
wwoytenko committed May 16, 2024
1 parent fcee37f commit 8b8a0a7
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 22 deletions.
2 changes: 1 addition & 1 deletion config.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ dump:
params:
ratio: 0.1
column: "test_float"
precision: 2
decimal: 2

restore:
pg_restore_options:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,16 +113,16 @@ Adds or subtracts a random duration in the provided `interval` to or from the or

### noiseFloat

Adds or subtracts a random fraction to or from the original float value. Multiplies the original float value by a provided random value that is not higher than the `ratio` parameter and adds it to the original value with the option to specify the precision via the `precision` parameter.
Adds or subtracts a random fraction to or from the original float value. Multiplies the original float value by a provided random value that is not higher than the `ratio` parameter and adds it to the original value with the option to specify the decimal via the `decimal` parameter.

=== "Signature"

`noiseFloat(ratio float, precision int, value float) (res float64, err error)`
`noiseFloat(ratio float, decimal int, value float) (res float64, err error)`

=== "Parameters"

* `ratio` — the maximum multiplier value in the interval (0:1). The value will be randomly generated up to `ratio`, multiplied by the original value, and the result will be added to the original value.
* `precision` — the precision of the resulted value
* `decimal` — the decimal of the resulted value
* `value` — the original value

=== "Return values"
Expand Down Expand Up @@ -176,13 +176,13 @@ Generates a random float value within the provided interval.

=== "Signature"

`randomFloat(min any, max any, precision int) (res float, err error)`
`randomFloat(min any, max any, decimal int) (res float, err error)`

=== "Parameters"

* `min` — the minimum random value threshold
* `max` — the maximum random value threshold
* `precision` — the precision of the resulted value
* `decimal` — the decimal of the resulted value

=== "Return values"

Expand Down Expand Up @@ -229,15 +229,15 @@ Generates a random string using the provided characters within the specified len

### roundFloat

Rounds a float value up to provided precision.
Rounds a float value up to provided decimal.

=== "Signature"

`roundFloat(precision int, original float) (res float, err error)`
`roundFloat(decimal int, original float) (res float, err error)`

=== "Parameters"

* `precision` — the precision of the value
* `decimal` — the decimal of the value
* `original` — the original float value

=== "Return values"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Add or subtract a random fraction to the original float value.
| Name | Description | Default | Required | Supported DB types |
|-----------|---------------------------------------------------------------------------------------------------|----------|----------|--------------------|
| column | The name of the column to be affected | | Yes | float4, float8 |
| precision | The precision of the noised float value (number of digits after the decimal point) | `4` | No | - |
| decimal | The decimal of the noised float value (number of digits after the decimal point) | `4` | No | - |
| min_ratio | The minimum random percentage for noise, from `0` to `1`, e. g. `0.1` means "add noise up to 10%" | `0.05` | No | - |
| max_ratio | The maximum random percentage for noise, from `0` to `1`, e. g. `0.1` means "add noise up to 10%" | | Yes | - |
| min | Min threshold of noised value | | No | - |
Expand All @@ -23,7 +23,7 @@ Add or subtract a random fraction to the original float value.

The `NoiseFloat` transformer multiplies the original float value by randomly generated value that is not higher than
the `max_ratio` parameter and not less that `max_ratio` parameter and adds it to or subtracts it from the original
value. Additionally, you can specify the number of decimal digits by using the `precision` parameter.
value. Additionally, you can specify the number of decimal digits by using the `decimal` parameter.

In case you have constraints on the float range, you can set the `min` and `max` parameters to specify the threshold
values. The values for `min` and `max` must have the same format as the `column` parameter. Parameters min and max
Expand Down Expand Up @@ -53,7 +53,7 @@ In this example, the original value of `standardprice` will be noised up to `50%
params:
column: "lastreceiptcost"
max_ratio: 0.15
precision: 2
decimal: 2
dynamic_params:
min:
column: "standardprice"
Expand Down
17 changes: 9 additions & 8 deletions docs/built_in_transformers/standard_transformers/random_float.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,24 @@ Generate a random float within the provided interval.

## Parameters

| Name | Description | Default | Required | Supported DB types |
|-----------|----------------------------------------------------------------------------------------|---------|----------|---------------------------------------------------|
| column | The name of the column to be affected | | Yes | float4 (real), float8 (double precision), numeric |
| Name | Description | Default | Required | Supported DB types |
|-----------|-----------------------------------------------------------------------------------------|---------|----------|---------------------------------------------------|
| column | The name of the column to be affected | | Yes | float4 (real), float8 (double precision), numeric |
| min | The minimum threshold for the random value. The value range depends on the column type. | | Yes | - |
| max | The maximum threshold for the random value. The value range depends on the column type. | | Yes | - |
| precision | The precision of the random float value (number of digits after the decimal point) | `4` | No | - |
| keep_null | Indicates whether NULL values should be replaced with transformed values or not | `true` | No | - |
| decimal | The decimal of the random float value (number of digits after the decimal point) | `4` | No | - |
| keep_null | Indicates whether NULL values should be replaced with transformed values or not | `true` | No | - |

## Description

The `RandomFloat` transformer generates a random float value within the provided interval, starting from `min` to
`max`, with the option to specify the number of decimal digits by using the `precision` parameter. The behaviour for NULL values can be configured using the `keep_null` parameter.
`max`, with the option to specify the number of decimal digits by using the `decimal` parameter. The behaviour for
NULL values can be configured using the `keep_null` parameter.

## Example: Generate random price

In this example, the `RandomFloat` transformer generates random prices in the range from `0.1` to `7000` while
maintaining a precision of up to 2 digits.
maintaining a decimal of up to 2 digits.

``` yaml title="RandomFloat transformer example"
- schema: "sales"
Expand All @@ -29,7 +30,7 @@ maintaining a precision of up to 2 digits.
column: "unitprice"
min: 0.1
max: 7000
precision: 2
decimal: 2
```
```bash title="Expected result"
Expand Down
4 changes: 2 additions & 2 deletions docs/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -522,8 +522,8 @@ their possible attributes. Below are the key parameters for each transformer:
"default_value": "MC4x"
},
{
"name": "precision",
"description": "precision of noised float value (number of digits after coma)",
"name": "decimal",
"description": "decimal of noised float value (number of digits after coma)",
"required": false,
"is_column": false,
"is_column_container": false,
Expand Down

0 comments on commit 8b8a0a7

Please sign in to comment.