From 6a7389272e179fadc3d502bf2f80e319241029c6 Mon Sep 17 00:00:00 2001
From: Younghoon Kim <yh.kim@databricks.com>
Date: Tue, 3 Dec 2024 09:50:33 -0800
Subject: [PATCH] fix(#9480): apply proper quote escapes for the datum access
 expression (#9479)

## PR Description

**Problem**

The expression like
```
`datum["${str}"]`
```
which is vulnerable when `str` has double quotes, such as `'hello,
"world"'`.

The expression with single quotes is the same
```
`datum['${str}']`
```
which is vulnerable when `str` has single quotes, such as `"Vega's
Favorite"`.

**Solution**
This PR fixes the existing datum access expression to have a proper
quote escape by calling `accessWithDatumToUnescapedPath`

It fixes the issue of timeunit band position transforms which don't
escape the field name correctly.

https://github.com/vega/vega-lite/issues/9480

---------

Co-authored-by: GitHub Actions Bot <vega-actions-bot@users.noreply.github.com>
---
 .../compiled/bar_grouped_errorbar.vg.json     |  4 +--
 .../compiled/boxplot_1D_horizontal.vg.json    |  4 +--
 .../boxplot_1D_horizontal_custom_mark.vg.json |  4 +--
 .../boxplot_1D_horizontal_explicit.vg.json    |  4 +--
 examples/compiled/boxplot_1D_invalid.vg.json  |  4 +--
 examples/compiled/boxplot_1D_vertical.vg.json |  4 +--
 .../compiled/boxplot_2D_horizontal.vg.json    |  4 +--
 .../boxplot_2D_horizontal_color_size.vg.json  |  4 +--
 examples/compiled/boxplot_2D_vertical.vg.json |  4 +--
 ...xplot_2D_vertical_single_per_group.vg.json |  4 +--
 ...2D_vertical_single_per_group_color.vg.json |  4 +--
 examples/compiled/boxplot_groupped.vg.json    |  4 +--
 .../boxplot_tooltip_aggregate.vg.json         |  4 +--
 .../boxplot_tooltip_not_aggregate.vg.json     |  4 +--
 examples/compiled/errorband_tooltip.vg.json   |  4 +--
 examples/compiled/errorbar_tooltip.vg.json    |  4 +--
 .../compiled/layer_boxplot_circle.vg.json     |  2 +-
 ...ayer_line_errorband_pre_aggregated.vg.json |  4 +--
 ...layer_point_errorbar_1d_horizontal.vg.json |  4 +--
 .../layer_point_errorbar_1d_vertical.vg.json  |  4 +--
 ...layer_point_errorbar_2d_horizontal.vg.json |  4 +--
 ...orbar_2d_horizontal_color_encoding.vg.json |  4 +--
 ...rrorbar_2d_horizontal_custom_ticks.vg.json |  4 +--
 ...point_errorbar_2d_horizontal_stdev.vg.json |  4 +--
 .../layer_point_errorbar_2d_vertical.vg.json  |  4 +--
 ...ar_pre_aggregated_asymmetric_error.vg.json |  4 +--
 ...bar_pre_aggregated_symmetric_error.vg.json |  4 +--
 ...rrorbar_pre_aggregated_upper_lower.vg.json |  4 +--
 .../layer_point_errorbar_stdev.vg.json        |  4 +--
 ...ter_errorband_1D_stdev_global_mean.vg.json |  4 +--
 .../layer_scatter_errorband_1d_stdev.vg.json  |  4 +--
 .../bar_grouped_errorbar_normalized.vl.json   |  4 +--
 ..._horizontal_custom_mark_normalized.vl.json |  4 +--
 ..._1D_horizontal_explicit_normalized.vl.json |  4 +--
 .../boxplot_1D_horizontal_normalized.vl.json  |  4 +--
 .../boxplot_1D_invalid_normalized.vl.json     |  4 +--
 .../boxplot_1D_vertical_normalized.vl.json    |  4 +--
 ...D_horizontal_color_size_normalized.vl.json |  4 +--
 .../boxplot_2D_horizontal_normalized.vl.json  |  4 +--
 .../boxplot_2D_vertical_normalized.vl.json    |  4 +--
 ..._single_per_group_color_normalized.vl.json |  4 +--
 ...rtical_single_per_group_normalized.vl.json |  4 +--
 .../boxplot_groupped_normalized.vl.json       |  4 +--
 ...xplot_tooltip_aggregate_normalized.vl.json |  4 +--
 ...t_tooltip_not_aggregate_normalized.vl.json |  4 +--
 .../errorband_tooltip_normalized.vl.json      |  4 +--
 .../errorbar_tooltip_normalized.vl.json       |  4 +--
 .../layer_boxplot_circle_normalized.vl.json   |  2 +-
 ...rrorband_pre_aggregated_normalized.vl.json |  4 +--
 ..._errorbar_1d_horizontal_normalized.vl.json |  4 +--
 ...nt_errorbar_1d_vertical_normalized.vl.json |  4 +--
 ...rizontal_color_encoding_normalized.vl.json |  4 +--
 ...horizontal_custom_ticks_normalized.vl.json |  4 +--
 ..._errorbar_2d_horizontal_normalized.vl.json |  4 +--
 ...bar_2d_horizontal_stdev_normalized.vl.json |  4 +--
 ...nt_errorbar_2d_vertical_normalized.vl.json |  4 +--
 ...egated_asymmetric_error_normalized.vl.json |  4 +--
 ...regated_symmetric_error_normalized.vl.json |  4 +--
 ..._aggregated_upper_lower_normalized.vl.json |  4 +--
 ...er_point_errorbar_stdev_normalized.vl.json |  4 +--
 ...nd_1D_stdev_global_mean_normalized.vl.json |  4 +--
 ...tter_errorband_1d_stdev_normalized.vl.json |  4 +--
 src/compile/data/timeunit.ts                  | 17 ++++++++---
 src/compositemark/boxplot.ts                  | 16 +++++-----
 src/compositemark/errorbar.ts                 | 21 +++++++------
 src/util.ts                                   | 17 +++++++++++
 test/compile/data/timeunit.test.ts            | 30 +++++++++++++++++++
 test/compositemark/boxplot.test.ts            |  4 +--
 test/compositemark/common.test.ts             |  4 +--
 test/compositemark/errorband.test.ts          |  4 +--
 test/compositemark/errorbar.test.ts           | 24 +++++++--------
 test/normalize/core.test.ts                   |  4 +--
 72 files changed, 222 insertions(+), 163 deletions(-)

diff --git a/examples/compiled/bar_grouped_errorbar.vg.json b/examples/compiled/bar_grouped_errorbar.vg.json
index 1e6a3ac463..592c784ac6 100644
--- a/examples/compiled/bar_grouped_errorbar.vg.json
+++ b/examples/compiled/bar_grouped_errorbar.vg.json
@@ -30,12 +30,12 @@
       "transform": [
         {
           "type": "formula",
-          "expr": "datum[\"center_Acceleration\"] + datum[\"extent_Acceleration\"]",
+          "expr": "datum['center_Acceleration'] + datum['extent_Acceleration']",
           "as": "upper_Acceleration"
         },
         {
           "type": "formula",
-          "expr": "datum[\"center_Acceleration\"] - datum[\"extent_Acceleration\"]",
+          "expr": "datum['center_Acceleration'] - datum['extent_Acceleration']",
           "as": "lower_Acceleration"
         },
         {
diff --git a/examples/compiled/boxplot_1D_horizontal.vg.json b/examples/compiled/boxplot_1D_horizontal.vg.json
index 717f0f259f..92556c6639 100644
--- a/examples/compiled/boxplot_1D_horizontal.vg.json
+++ b/examples/compiled/boxplot_1D_horizontal.vg.json
@@ -31,7 +31,7 @@
       "transform": [
         {
           "type": "filter",
-          "expr": "(datum[\"Body Mass (g)\"] < datum[\"lower_box_Body Mass (g)\"] - 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"])) || (datum[\"Body Mass (g)\"] > datum[\"upper_box_Body Mass (g)\"] + 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"]))"
+          "expr": "(datum['Body Mass (g)'] < datum['lower_box_Body Mass (g)'] - 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)'])) || (datum['Body Mass (g)'] > datum['upper_box_Body Mass (g)'] + 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)']))"
         },
         {
           "type": "filter",
@@ -45,7 +45,7 @@
       "transform": [
         {
           "type": "filter",
-          "expr": "(datum[\"lower_box_Body Mass (g)\"] - 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"]) <= datum[\"Body Mass (g)\"]) && (datum[\"Body Mass (g)\"] <= datum[\"upper_box_Body Mass (g)\"] + 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"]))"
+          "expr": "(datum['lower_box_Body Mass (g)'] - 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)']) <= datum['Body Mass (g)']) && (datum['Body Mass (g)'] <= datum['upper_box_Body Mass (g)'] + 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)']))"
         },
         {
           "type": "aggregate",
diff --git a/examples/compiled/boxplot_1D_horizontal_custom_mark.vg.json b/examples/compiled/boxplot_1D_horizontal_custom_mark.vg.json
index 776537f73c..6709a39636 100644
--- a/examples/compiled/boxplot_1D_horizontal_custom_mark.vg.json
+++ b/examples/compiled/boxplot_1D_horizontal_custom_mark.vg.json
@@ -31,7 +31,7 @@
       "transform": [
         {
           "type": "filter",
-          "expr": "(datum[\"Body Mass (g)\"] < datum[\"lower_box_Body Mass (g)\"] - 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"])) || (datum[\"Body Mass (g)\"] > datum[\"upper_box_Body Mass (g)\"] + 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"]))"
+          "expr": "(datum['Body Mass (g)'] < datum['lower_box_Body Mass (g)'] - 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)'])) || (datum['Body Mass (g)'] > datum['upper_box_Body Mass (g)'] + 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)']))"
         },
         {
           "type": "filter",
@@ -45,7 +45,7 @@
       "transform": [
         {
           "type": "filter",
-          "expr": "(datum[\"lower_box_Body Mass (g)\"] - 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"]) <= datum[\"Body Mass (g)\"]) && (datum[\"Body Mass (g)\"] <= datum[\"upper_box_Body Mass (g)\"] + 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"]))"
+          "expr": "(datum['lower_box_Body Mass (g)'] - 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)']) <= datum['Body Mass (g)']) && (datum['Body Mass (g)'] <= datum['upper_box_Body Mass (g)'] + 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)']))"
         },
         {
           "type": "aggregate",
diff --git a/examples/compiled/boxplot_1D_horizontal_explicit.vg.json b/examples/compiled/boxplot_1D_horizontal_explicit.vg.json
index 717f0f259f..92556c6639 100644
--- a/examples/compiled/boxplot_1D_horizontal_explicit.vg.json
+++ b/examples/compiled/boxplot_1D_horizontal_explicit.vg.json
@@ -31,7 +31,7 @@
       "transform": [
         {
           "type": "filter",
-          "expr": "(datum[\"Body Mass (g)\"] < datum[\"lower_box_Body Mass (g)\"] - 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"])) || (datum[\"Body Mass (g)\"] > datum[\"upper_box_Body Mass (g)\"] + 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"]))"
+          "expr": "(datum['Body Mass (g)'] < datum['lower_box_Body Mass (g)'] - 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)'])) || (datum['Body Mass (g)'] > datum['upper_box_Body Mass (g)'] + 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)']))"
         },
         {
           "type": "filter",
@@ -45,7 +45,7 @@
       "transform": [
         {
           "type": "filter",
-          "expr": "(datum[\"lower_box_Body Mass (g)\"] - 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"]) <= datum[\"Body Mass (g)\"]) && (datum[\"Body Mass (g)\"] <= datum[\"upper_box_Body Mass (g)\"] + 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"]))"
+          "expr": "(datum['lower_box_Body Mass (g)'] - 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)']) <= datum['Body Mass (g)']) && (datum['Body Mass (g)'] <= datum['upper_box_Body Mass (g)'] + 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)']))"
         },
         {
           "type": "aggregate",
diff --git a/examples/compiled/boxplot_1D_invalid.vg.json b/examples/compiled/boxplot_1D_invalid.vg.json
index ff84dca834..fe54f15cb5 100644
--- a/examples/compiled/boxplot_1D_invalid.vg.json
+++ b/examples/compiled/boxplot_1D_invalid.vg.json
@@ -36,7 +36,7 @@
       "transform": [
         {
           "type": "filter",
-          "expr": "(datum[\"b\"] < datum[\"lower_box_b\"] - 1.5 * (datum[\"upper_box_b\"] - datum[\"lower_box_b\"])) || (datum[\"b\"] > datum[\"upper_box_b\"] + 1.5 * (datum[\"upper_box_b\"] - datum[\"lower_box_b\"]))"
+          "expr": "(datum['b'] < datum['lower_box_b'] - 1.5 * (datum['upper_box_b'] - datum['lower_box_b'])) || (datum['b'] > datum['upper_box_b'] + 1.5 * (datum['upper_box_b'] - datum['lower_box_b']))"
         },
         {
           "type": "filter",
@@ -50,7 +50,7 @@
       "transform": [
         {
           "type": "filter",
-          "expr": "(datum[\"lower_box_b\"] - 1.5 * (datum[\"upper_box_b\"] - datum[\"lower_box_b\"]) <= datum[\"b\"]) && (datum[\"b\"] <= datum[\"upper_box_b\"] + 1.5 * (datum[\"upper_box_b\"] - datum[\"lower_box_b\"]))"
+          "expr": "(datum['lower_box_b'] - 1.5 * (datum['upper_box_b'] - datum['lower_box_b']) <= datum['b']) && (datum['b'] <= datum['upper_box_b'] + 1.5 * (datum['upper_box_b'] - datum['lower_box_b']))"
         },
         {
           "type": "aggregate",
diff --git a/examples/compiled/boxplot_1D_vertical.vg.json b/examples/compiled/boxplot_1D_vertical.vg.json
index ae064d4290..5d4fbd5778 100644
--- a/examples/compiled/boxplot_1D_vertical.vg.json
+++ b/examples/compiled/boxplot_1D_vertical.vg.json
@@ -31,7 +31,7 @@
       "transform": [
         {
           "type": "filter",
-          "expr": "(datum[\"Body Mass (g)\"] < datum[\"lower_box_Body Mass (g)\"] - 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"])) || (datum[\"Body Mass (g)\"] > datum[\"upper_box_Body Mass (g)\"] + 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"]))"
+          "expr": "(datum['Body Mass (g)'] < datum['lower_box_Body Mass (g)'] - 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)'])) || (datum['Body Mass (g)'] > datum['upper_box_Body Mass (g)'] + 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)']))"
         },
         {
           "type": "filter",
@@ -45,7 +45,7 @@
       "transform": [
         {
           "type": "filter",
-          "expr": "(datum[\"lower_box_Body Mass (g)\"] - 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"]) <= datum[\"Body Mass (g)\"]) && (datum[\"Body Mass (g)\"] <= datum[\"upper_box_Body Mass (g)\"] + 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"]))"
+          "expr": "(datum['lower_box_Body Mass (g)'] - 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)']) <= datum['Body Mass (g)']) && (datum['Body Mass (g)'] <= datum['upper_box_Body Mass (g)'] + 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)']))"
         },
         {
           "type": "aggregate",
diff --git a/examples/compiled/boxplot_2D_horizontal.vg.json b/examples/compiled/boxplot_2D_horizontal.vg.json
index eddb366808..64d44c2540 100644
--- a/examples/compiled/boxplot_2D_horizontal.vg.json
+++ b/examples/compiled/boxplot_2D_horizontal.vg.json
@@ -30,7 +30,7 @@
       "transform": [
         {
           "type": "filter",
-          "expr": "(datum[\"Body Mass (g)\"] < datum[\"lower_box_Body Mass (g)\"] - 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"])) || (datum[\"Body Mass (g)\"] > datum[\"upper_box_Body Mass (g)\"] + 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"]))"
+          "expr": "(datum['Body Mass (g)'] < datum['lower_box_Body Mass (g)'] - 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)'])) || (datum['Body Mass (g)'] > datum['upper_box_Body Mass (g)'] + 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)']))"
         },
         {
           "type": "filter",
@@ -44,7 +44,7 @@
       "transform": [
         {
           "type": "filter",
-          "expr": "(datum[\"lower_box_Body Mass (g)\"] - 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"]) <= datum[\"Body Mass (g)\"]) && (datum[\"Body Mass (g)\"] <= datum[\"upper_box_Body Mass (g)\"] + 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"]))"
+          "expr": "(datum['lower_box_Body Mass (g)'] - 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)']) <= datum['Body Mass (g)']) && (datum['Body Mass (g)'] <= datum['upper_box_Body Mass (g)'] + 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)']))"
         },
         {
           "type": "aggregate",
diff --git a/examples/compiled/boxplot_2D_horizontal_color_size.vg.json b/examples/compiled/boxplot_2D_horizontal_color_size.vg.json
index 9b69f67750..e3f9889449 100644
--- a/examples/compiled/boxplot_2D_horizontal_color_size.vg.json
+++ b/examples/compiled/boxplot_2D_horizontal_color_size.vg.json
@@ -30,7 +30,7 @@
       "transform": [
         {
           "type": "filter",
-          "expr": "(datum[\"Body Mass (g)\"] < datum[\"lower_box_Body Mass (g)\"] - 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"])) || (datum[\"Body Mass (g)\"] > datum[\"upper_box_Body Mass (g)\"] + 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"]))"
+          "expr": "(datum['Body Mass (g)'] < datum['lower_box_Body Mass (g)'] - 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)'])) || (datum['Body Mass (g)'] > datum['upper_box_Body Mass (g)'] + 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)']))"
         },
         {
           "type": "filter",
@@ -44,7 +44,7 @@
       "transform": [
         {
           "type": "filter",
-          "expr": "(datum[\"lower_box_Body Mass (g)\"] - 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"]) <= datum[\"Body Mass (g)\"]) && (datum[\"Body Mass (g)\"] <= datum[\"upper_box_Body Mass (g)\"] + 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"]))"
+          "expr": "(datum['lower_box_Body Mass (g)'] - 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)']) <= datum['Body Mass (g)']) && (datum['Body Mass (g)'] <= datum['upper_box_Body Mass (g)'] + 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)']))"
         },
         {
           "type": "aggregate",
diff --git a/examples/compiled/boxplot_2D_vertical.vg.json b/examples/compiled/boxplot_2D_vertical.vg.json
index c3e870d09d..7476612122 100644
--- a/examples/compiled/boxplot_2D_vertical.vg.json
+++ b/examples/compiled/boxplot_2D_vertical.vg.json
@@ -30,7 +30,7 @@
       "transform": [
         {
           "type": "filter",
-          "expr": "(datum[\"Body Mass (g)\"] < datum[\"lower_box_Body Mass (g)\"] - 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"])) || (datum[\"Body Mass (g)\"] > datum[\"upper_box_Body Mass (g)\"] + 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"]))"
+          "expr": "(datum['Body Mass (g)'] < datum['lower_box_Body Mass (g)'] - 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)'])) || (datum['Body Mass (g)'] > datum['upper_box_Body Mass (g)'] + 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)']))"
         },
         {
           "type": "filter",
@@ -44,7 +44,7 @@
       "transform": [
         {
           "type": "filter",
-          "expr": "(datum[\"lower_box_Body Mass (g)\"] - 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"]) <= datum[\"Body Mass (g)\"]) && (datum[\"Body Mass (g)\"] <= datum[\"upper_box_Body Mass (g)\"] + 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"]))"
+          "expr": "(datum['lower_box_Body Mass (g)'] - 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)']) <= datum['Body Mass (g)']) && (datum['Body Mass (g)'] <= datum['upper_box_Body Mass (g)'] + 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)']))"
         },
         {
           "type": "aggregate",
diff --git a/examples/compiled/boxplot_2D_vertical_single_per_group.vg.json b/examples/compiled/boxplot_2D_vertical_single_per_group.vg.json
index aaf6d6723e..b2bcb83a82 100644
--- a/examples/compiled/boxplot_2D_vertical_single_per_group.vg.json
+++ b/examples/compiled/boxplot_2D_vertical_single_per_group.vg.json
@@ -29,7 +29,7 @@
       "transform": [
         {
           "type": "filter",
-          "expr": "(datum[\"b\"] < datum[\"lower_box_b\"] - 1.5 * (datum[\"upper_box_b\"] - datum[\"lower_box_b\"])) || (datum[\"b\"] > datum[\"upper_box_b\"] + 1.5 * (datum[\"upper_box_b\"] - datum[\"lower_box_b\"]))"
+          "expr": "(datum['b'] < datum['lower_box_b'] - 1.5 * (datum['upper_box_b'] - datum['lower_box_b'])) || (datum['b'] > datum['upper_box_b'] + 1.5 * (datum['upper_box_b'] - datum['lower_box_b']))"
         },
         {
           "type": "filter",
@@ -43,7 +43,7 @@
       "transform": [
         {
           "type": "filter",
-          "expr": "(datum[\"lower_box_b\"] - 1.5 * (datum[\"upper_box_b\"] - datum[\"lower_box_b\"]) <= datum[\"b\"]) && (datum[\"b\"] <= datum[\"upper_box_b\"] + 1.5 * (datum[\"upper_box_b\"] - datum[\"lower_box_b\"]))"
+          "expr": "(datum['lower_box_b'] - 1.5 * (datum['upper_box_b'] - datum['lower_box_b']) <= datum['b']) && (datum['b'] <= datum['upper_box_b'] + 1.5 * (datum['upper_box_b'] - datum['lower_box_b']))"
         },
         {
           "type": "aggregate",
diff --git a/examples/compiled/boxplot_2D_vertical_single_per_group_color.vg.json b/examples/compiled/boxplot_2D_vertical_single_per_group_color.vg.json
index 3d46d99a2e..809c7835c2 100644
--- a/examples/compiled/boxplot_2D_vertical_single_per_group_color.vg.json
+++ b/examples/compiled/boxplot_2D_vertical_single_per_group_color.vg.json
@@ -29,7 +29,7 @@
       "transform": [
         {
           "type": "filter",
-          "expr": "(datum[\"b\"] < datum[\"lower_box_b\"] - 1.5 * (datum[\"upper_box_b\"] - datum[\"lower_box_b\"])) || (datum[\"b\"] > datum[\"upper_box_b\"] + 1.5 * (datum[\"upper_box_b\"] - datum[\"lower_box_b\"]))"
+          "expr": "(datum['b'] < datum['lower_box_b'] - 1.5 * (datum['upper_box_b'] - datum['lower_box_b'])) || (datum['b'] > datum['upper_box_b'] + 1.5 * (datum['upper_box_b'] - datum['lower_box_b']))"
         },
         {
           "type": "filter",
@@ -43,7 +43,7 @@
       "transform": [
         {
           "type": "filter",
-          "expr": "(datum[\"lower_box_b\"] - 1.5 * (datum[\"upper_box_b\"] - datum[\"lower_box_b\"]) <= datum[\"b\"]) && (datum[\"b\"] <= datum[\"upper_box_b\"] + 1.5 * (datum[\"upper_box_b\"] - datum[\"lower_box_b\"]))"
+          "expr": "(datum['lower_box_b'] - 1.5 * (datum['upper_box_b'] - datum['lower_box_b']) <= datum['b']) && (datum['b'] <= datum['upper_box_b'] + 1.5 * (datum['upper_box_b'] - datum['lower_box_b']))"
         },
         {
           "type": "aggregate",
diff --git a/examples/compiled/boxplot_groupped.vg.json b/examples/compiled/boxplot_groupped.vg.json
index 258c7b6518..57694094f2 100644
--- a/examples/compiled/boxplot_groupped.vg.json
+++ b/examples/compiled/boxplot_groupped.vg.json
@@ -26,7 +26,7 @@
       "transform": [
         {
           "type": "filter",
-          "expr": "(datum[\"Acceleration\"] < datum[\"lower_box_Acceleration\"] - 1.5 * (datum[\"upper_box_Acceleration\"] - datum[\"lower_box_Acceleration\"])) || (datum[\"Acceleration\"] > datum[\"upper_box_Acceleration\"] + 1.5 * (datum[\"upper_box_Acceleration\"] - datum[\"lower_box_Acceleration\"]))"
+          "expr": "(datum['Acceleration'] < datum['lower_box_Acceleration'] - 1.5 * (datum['upper_box_Acceleration'] - datum['lower_box_Acceleration'])) || (datum['Acceleration'] > datum['upper_box_Acceleration'] + 1.5 * (datum['upper_box_Acceleration'] - datum['lower_box_Acceleration']))"
         },
         {
           "type": "filter",
@@ -40,7 +40,7 @@
       "transform": [
         {
           "type": "filter",
-          "expr": "(datum[\"lower_box_Acceleration\"] - 1.5 * (datum[\"upper_box_Acceleration\"] - datum[\"lower_box_Acceleration\"]) <= datum[\"Acceleration\"]) && (datum[\"Acceleration\"] <= datum[\"upper_box_Acceleration\"] + 1.5 * (datum[\"upper_box_Acceleration\"] - datum[\"lower_box_Acceleration\"]))"
+          "expr": "(datum['lower_box_Acceleration'] - 1.5 * (datum['upper_box_Acceleration'] - datum['lower_box_Acceleration']) <= datum['Acceleration']) && (datum['Acceleration'] <= datum['upper_box_Acceleration'] + 1.5 * (datum['upper_box_Acceleration'] - datum['lower_box_Acceleration']))"
         },
         {
           "type": "aggregate",
diff --git a/examples/compiled/boxplot_tooltip_aggregate.vg.json b/examples/compiled/boxplot_tooltip_aggregate.vg.json
index 21dbd804b4..8875b7816a 100644
--- a/examples/compiled/boxplot_tooltip_aggregate.vg.json
+++ b/examples/compiled/boxplot_tooltip_aggregate.vg.json
@@ -30,7 +30,7 @@
       "transform": [
         {
           "type": "filter",
-          "expr": "(datum[\"Body Mass (g)\"] < datum[\"lower_box_Body Mass (g)\"] - 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"])) || (datum[\"Body Mass (g)\"] > datum[\"upper_box_Body Mass (g)\"] + 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"]))"
+          "expr": "(datum['Body Mass (g)'] < datum['lower_box_Body Mass (g)'] - 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)'])) || (datum['Body Mass (g)'] > datum['upper_box_Body Mass (g)'] + 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)']))"
         },
         {
           "type": "filter",
@@ -44,7 +44,7 @@
       "transform": [
         {
           "type": "filter",
-          "expr": "(datum[\"lower_box_Body Mass (g)\"] - 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"]) <= datum[\"Body Mass (g)\"]) && (datum[\"Body Mass (g)\"] <= datum[\"upper_box_Body Mass (g)\"] + 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"]))"
+          "expr": "(datum['lower_box_Body Mass (g)'] - 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)']) <= datum['Body Mass (g)']) && (datum['Body Mass (g)'] <= datum['upper_box_Body Mass (g)'] + 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)']))"
         },
         {
           "type": "aggregate",
diff --git a/examples/compiled/boxplot_tooltip_not_aggregate.vg.json b/examples/compiled/boxplot_tooltip_not_aggregate.vg.json
index 8c5512a3ba..20fcc36827 100644
--- a/examples/compiled/boxplot_tooltip_not_aggregate.vg.json
+++ b/examples/compiled/boxplot_tooltip_not_aggregate.vg.json
@@ -30,7 +30,7 @@
       "transform": [
         {
           "type": "filter",
-          "expr": "(datum[\"Body Mass (g)\"] < datum[\"lower_box_Body Mass (g)\"] - 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"])) || (datum[\"Body Mass (g)\"] > datum[\"upper_box_Body Mass (g)\"] + 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"]))"
+          "expr": "(datum['Body Mass (g)'] < datum['lower_box_Body Mass (g)'] - 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)'])) || (datum['Body Mass (g)'] > datum['upper_box_Body Mass (g)'] + 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)']))"
         },
         {
           "type": "filter",
@@ -44,7 +44,7 @@
       "transform": [
         {
           "type": "filter",
-          "expr": "(datum[\"lower_box_Body Mass (g)\"] - 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"]) <= datum[\"Body Mass (g)\"]) && (datum[\"Body Mass (g)\"] <= datum[\"upper_box_Body Mass (g)\"] + 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"]))"
+          "expr": "(datum['lower_box_Body Mass (g)'] - 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)']) <= datum['Body Mass (g)']) && (datum['Body Mass (g)'] <= datum['upper_box_Body Mass (g)'] + 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)']))"
         },
         {
           "type": "aggregate",
diff --git a/examples/compiled/errorband_tooltip.vg.json b/examples/compiled/errorband_tooltip.vg.json
index 5dc465efe4..ba493645e7 100644
--- a/examples/compiled/errorband_tooltip.vg.json
+++ b/examples/compiled/errorband_tooltip.vg.json
@@ -26,12 +26,12 @@
         },
         {
           "type": "formula",
-          "expr": "datum[\"center_Miles_per_Gallon\"] + datum[\"extent_Miles_per_Gallon\"]",
+          "expr": "datum['center_Miles_per_Gallon'] + datum['extent_Miles_per_Gallon']",
           "as": "upper_Miles_per_Gallon"
         },
         {
           "type": "formula",
-          "expr": "datum[\"center_Miles_per_Gallon\"] - datum[\"extent_Miles_per_Gallon\"]",
+          "expr": "datum['center_Miles_per_Gallon'] - datum['extent_Miles_per_Gallon']",
           "as": "lower_Miles_per_Gallon"
         }
       ]
diff --git a/examples/compiled/errorbar_tooltip.vg.json b/examples/compiled/errorbar_tooltip.vg.json
index 21572cd9cd..5f8391407b 100644
--- a/examples/compiled/errorbar_tooltip.vg.json
+++ b/examples/compiled/errorbar_tooltip.vg.json
@@ -19,12 +19,12 @@
         },
         {
           "type": "formula",
-          "expr": "datum[\"center_yield\"] + datum[\"extent_yield\"]",
+          "expr": "datum['center_yield'] + datum['extent_yield']",
           "as": "upper_yield"
         },
         {
           "type": "formula",
-          "expr": "datum[\"center_yield\"] - datum[\"extent_yield\"]",
+          "expr": "datum['center_yield'] - datum['extent_yield']",
           "as": "lower_yield"
         },
         {
diff --git a/examples/compiled/layer_boxplot_circle.vg.json b/examples/compiled/layer_boxplot_circle.vg.json
index 96d93c3eb2..796231577c 100644
--- a/examples/compiled/layer_boxplot_circle.vg.json
+++ b/examples/compiled/layer_boxplot_circle.vg.json
@@ -24,7 +24,7 @@
         },
         {
           "type": "filter",
-          "expr": "(datum[\"lower_box_people\"] - 1.5 * (datum[\"upper_box_people\"] - datum[\"lower_box_people\"]) <= datum[\"people\"]) && (datum[\"people\"] <= datum[\"upper_box_people\"] + 1.5 * (datum[\"upper_box_people\"] - datum[\"lower_box_people\"]))"
+          "expr": "(datum['lower_box_people'] - 1.5 * (datum['upper_box_people'] - datum['lower_box_people']) <= datum['people']) && (datum['people'] <= datum['upper_box_people'] + 1.5 * (datum['upper_box_people'] - datum['lower_box_people']))"
         },
         {
           "type": "aggregate",
diff --git a/examples/compiled/layer_line_errorband_pre_aggregated.vg.json b/examples/compiled/layer_line_errorband_pre_aggregated.vg.json
index ec42299e65..1f723da821 100644
--- a/examples/compiled/layer_line_errorband_pre_aggregated.vg.json
+++ b/examples/compiled/layer_line_errorband_pre_aggregated.vg.json
@@ -52,8 +52,8 @@
       "name": "data_1",
       "source": "data_0",
       "transform": [
-        {"type": "formula", "expr": "datum[\"ci0\"]", "as": "upper_ci1"},
-        {"type": "formula", "expr": "datum[\"ci1\"]", "as": "lower_ci1"}
+        {"type": "formula", "expr": "datum['ci0']", "as": "upper_ci1"},
+        {"type": "formula", "expr": "datum['ci1']", "as": "lower_ci1"}
       ]
     }
   ],
diff --git a/examples/compiled/layer_point_errorbar_1d_horizontal.vg.json b/examples/compiled/layer_point_errorbar_1d_horizontal.vg.json
index 306057e4fd..d4cde6a165 100644
--- a/examples/compiled/layer_point_errorbar_1d_horizontal.vg.json
+++ b/examples/compiled/layer_point_errorbar_1d_horizontal.vg.json
@@ -36,12 +36,12 @@
       "transform": [
         {
           "type": "formula",
-          "expr": "datum[\"center_yield\"] + datum[\"extent_yield\"]",
+          "expr": "datum['center_yield'] + datum['extent_yield']",
           "as": "upper_yield"
         },
         {
           "type": "formula",
-          "expr": "datum[\"center_yield\"] - datum[\"extent_yield\"]",
+          "expr": "datum['center_yield'] - datum['extent_yield']",
           "as": "lower_yield"
         },
         {
diff --git a/examples/compiled/layer_point_errorbar_1d_vertical.vg.json b/examples/compiled/layer_point_errorbar_1d_vertical.vg.json
index 50011daa62..1f61c232a4 100644
--- a/examples/compiled/layer_point_errorbar_1d_vertical.vg.json
+++ b/examples/compiled/layer_point_errorbar_1d_vertical.vg.json
@@ -36,12 +36,12 @@
       "transform": [
         {
           "type": "formula",
-          "expr": "datum[\"center_yield\"] + datum[\"extent_yield\"]",
+          "expr": "datum['center_yield'] + datum['extent_yield']",
           "as": "upper_yield"
         },
         {
           "type": "formula",
-          "expr": "datum[\"center_yield\"] - datum[\"extent_yield\"]",
+          "expr": "datum['center_yield'] - datum['extent_yield']",
           "as": "lower_yield"
         },
         {
diff --git a/examples/compiled/layer_point_errorbar_2d_horizontal.vg.json b/examples/compiled/layer_point_errorbar_2d_horizontal.vg.json
index 672ec33639..15f59a9775 100644
--- a/examples/compiled/layer_point_errorbar_2d_horizontal.vg.json
+++ b/examples/compiled/layer_point_errorbar_2d_horizontal.vg.json
@@ -35,12 +35,12 @@
       "transform": [
         {
           "type": "formula",
-          "expr": "datum[\"center_yield\"] + datum[\"extent_yield\"]",
+          "expr": "datum['center_yield'] + datum['extent_yield']",
           "as": "upper_yield"
         },
         {
           "type": "formula",
-          "expr": "datum[\"center_yield\"] - datum[\"extent_yield\"]",
+          "expr": "datum['center_yield'] - datum['extent_yield']",
           "as": "lower_yield"
         },
         {
diff --git a/examples/compiled/layer_point_errorbar_2d_horizontal_color_encoding.vg.json b/examples/compiled/layer_point_errorbar_2d_horizontal_color_encoding.vg.json
index 443e0c3f29..4a4a129f46 100644
--- a/examples/compiled/layer_point_errorbar_2d_horizontal_color_encoding.vg.json
+++ b/examples/compiled/layer_point_errorbar_2d_horizontal_color_encoding.vg.json
@@ -35,12 +35,12 @@
       "transform": [
         {
           "type": "formula",
-          "expr": "datum[\"center_yield\"] + datum[\"extent_yield\"]",
+          "expr": "datum['center_yield'] + datum['extent_yield']",
           "as": "upper_yield"
         },
         {
           "type": "formula",
-          "expr": "datum[\"center_yield\"] - datum[\"extent_yield\"]",
+          "expr": "datum['center_yield'] - datum['extent_yield']",
           "as": "lower_yield"
         }
       ]
diff --git a/examples/compiled/layer_point_errorbar_2d_horizontal_custom_ticks.vg.json b/examples/compiled/layer_point_errorbar_2d_horizontal_custom_ticks.vg.json
index 77a39ccee1..01b801afca 100644
--- a/examples/compiled/layer_point_errorbar_2d_horizontal_custom_ticks.vg.json
+++ b/examples/compiled/layer_point_errorbar_2d_horizontal_custom_ticks.vg.json
@@ -35,12 +35,12 @@
       "transform": [
         {
           "type": "formula",
-          "expr": "datum[\"center_yield\"] + datum[\"extent_yield\"]",
+          "expr": "datum['center_yield'] + datum['extent_yield']",
           "as": "upper_yield"
         },
         {
           "type": "formula",
-          "expr": "datum[\"center_yield\"] - datum[\"extent_yield\"]",
+          "expr": "datum['center_yield'] - datum['extent_yield']",
           "as": "lower_yield"
         }
       ]
diff --git a/examples/compiled/layer_point_errorbar_2d_horizontal_stdev.vg.json b/examples/compiled/layer_point_errorbar_2d_horizontal_stdev.vg.json
index 76ec714e4b..9c7584b42e 100644
--- a/examples/compiled/layer_point_errorbar_2d_horizontal_stdev.vg.json
+++ b/examples/compiled/layer_point_errorbar_2d_horizontal_stdev.vg.json
@@ -35,12 +35,12 @@
       "transform": [
         {
           "type": "formula",
-          "expr": "datum[\"center_yield\"] + datum[\"extent_yield\"]",
+          "expr": "datum['center_yield'] + datum['extent_yield']",
           "as": "upper_yield"
         },
         {
           "type": "formula",
-          "expr": "datum[\"center_yield\"] - datum[\"extent_yield\"]",
+          "expr": "datum['center_yield'] - datum['extent_yield']",
           "as": "lower_yield"
         },
         {
diff --git a/examples/compiled/layer_point_errorbar_2d_vertical.vg.json b/examples/compiled/layer_point_errorbar_2d_vertical.vg.json
index 40ebf0cb7b..cd3e8daaed 100644
--- a/examples/compiled/layer_point_errorbar_2d_vertical.vg.json
+++ b/examples/compiled/layer_point_errorbar_2d_vertical.vg.json
@@ -35,12 +35,12 @@
       "transform": [
         {
           "type": "formula",
-          "expr": "datum[\"center_yield\"] + datum[\"extent_yield\"]",
+          "expr": "datum['center_yield'] + datum['extent_yield']",
           "as": "upper_yield"
         },
         {
           "type": "formula",
-          "expr": "datum[\"center_yield\"] - datum[\"extent_yield\"]",
+          "expr": "datum['center_yield'] - datum['extent_yield']",
           "as": "lower_yield"
         },
         {
diff --git a/examples/compiled/layer_point_errorbar_pre_aggregated_asymmetric_error.vg.json b/examples/compiled/layer_point_errorbar_pre_aggregated_asymmetric_error.vg.json
index c4920cf063..a622087510 100644
--- a/examples/compiled/layer_point_errorbar_pre_aggregated_asymmetric_error.vg.json
+++ b/examples/compiled/layer_point_errorbar_pre_aggregated_asymmetric_error.vg.json
@@ -40,12 +40,12 @@
       "transform": [
         {
           "type": "formula",
-          "expr": "datum[\"yield_center\"] + datum[\"yield_error\"]",
+          "expr": "datum['yield_center'] + datum['yield_error']",
           "as": "upper_yield_center"
         },
         {
           "type": "formula",
-          "expr": "datum[\"yield_center\"] + datum[\"yield_error2\"]",
+          "expr": "datum['yield_center'] + datum['yield_error2']",
           "as": "lower_yield_center"
         },
         {
diff --git a/examples/compiled/layer_point_errorbar_pre_aggregated_symmetric_error.vg.json b/examples/compiled/layer_point_errorbar_pre_aggregated_symmetric_error.vg.json
index 05fc1ffb53..44d400cca8 100644
--- a/examples/compiled/layer_point_errorbar_pre_aggregated_symmetric_error.vg.json
+++ b/examples/compiled/layer_point_errorbar_pre_aggregated_symmetric_error.vg.json
@@ -28,12 +28,12 @@
       "transform": [
         {
           "type": "formula",
-          "expr": "datum[\"yield_center\"] + datum[\"yield_error\"]",
+          "expr": "datum['yield_center'] + datum['yield_error']",
           "as": "upper_yield_center"
         },
         {
           "type": "formula",
-          "expr": "datum[\"yield_center\"] - datum[\"yield_error\"]",
+          "expr": "datum['yield_center'] - datum['yield_error']",
           "as": "lower_yield_center"
         },
         {
diff --git a/examples/compiled/layer_point_errorbar_pre_aggregated_upper_lower.vg.json b/examples/compiled/layer_point_errorbar_pre_aggregated_upper_lower.vg.json
index 7ee0833181..1f959353dc 100644
--- a/examples/compiled/layer_point_errorbar_pre_aggregated_upper_lower.vg.json
+++ b/examples/compiled/layer_point_errorbar_pre_aggregated_upper_lower.vg.json
@@ -40,12 +40,12 @@
       "transform": [
         {
           "type": "formula",
-          "expr": "datum[\"lower_yield\"]",
+          "expr": "datum['lower_yield']",
           "as": "upper_upper_yield"
         },
         {
           "type": "formula",
-          "expr": "datum[\"upper_yield\"]",
+          "expr": "datum['upper_yield']",
           "as": "lower_upper_yield"
         },
         {
diff --git a/examples/compiled/layer_point_errorbar_stdev.vg.json b/examples/compiled/layer_point_errorbar_stdev.vg.json
index a94650dfa7..48d896eaf1 100644
--- a/examples/compiled/layer_point_errorbar_stdev.vg.json
+++ b/examples/compiled/layer_point_errorbar_stdev.vg.json
@@ -25,12 +25,12 @@
       "transform": [
         {
           "type": "formula",
-          "expr": "datum[\"center_yield\"] + datum[\"extent_yield\"]",
+          "expr": "datum['center_yield'] + datum['extent_yield']",
           "as": "upper_yield"
         },
         {
           "type": "formula",
-          "expr": "datum[\"center_yield\"] - datum[\"extent_yield\"]",
+          "expr": "datum['center_yield'] - datum['extent_yield']",
           "as": "lower_yield"
         },
         {
diff --git a/examples/compiled/layer_scatter_errorband_1D_stdev_global_mean.vg.json b/examples/compiled/layer_scatter_errorband_1D_stdev_global_mean.vg.json
index bc686f03d5..a5ca1aeb47 100644
--- a/examples/compiled/layer_scatter_errorband_1D_stdev_global_mean.vg.json
+++ b/examples/compiled/layer_scatter_errorband_1D_stdev_global_mean.vg.json
@@ -55,12 +55,12 @@
       "transform": [
         {
           "type": "formula",
-          "expr": "datum[\"center_Miles_per_Gallon\"] + datum[\"extent_Miles_per_Gallon\"]",
+          "expr": "datum['center_Miles_per_Gallon'] + datum['extent_Miles_per_Gallon']",
           "as": "upper_Miles_per_Gallon"
         },
         {
           "type": "formula",
-          "expr": "datum[\"center_Miles_per_Gallon\"] - datum[\"extent_Miles_per_Gallon\"]",
+          "expr": "datum['center_Miles_per_Gallon'] - datum['extent_Miles_per_Gallon']",
           "as": "lower_Miles_per_Gallon"
         },
         {
diff --git a/examples/compiled/layer_scatter_errorband_1d_stdev.vg.json b/examples/compiled/layer_scatter_errorband_1d_stdev.vg.json
index e19f0d8252..f59f30fb20 100644
--- a/examples/compiled/layer_scatter_errorband_1d_stdev.vg.json
+++ b/examples/compiled/layer_scatter_errorband_1d_stdev.vg.json
@@ -30,12 +30,12 @@
         },
         {
           "type": "formula",
-          "expr": "datum[\"center_Miles_per_Gallon\"] + datum[\"extent_Miles_per_Gallon\"]",
+          "expr": "datum['center_Miles_per_Gallon'] + datum['extent_Miles_per_Gallon']",
           "as": "upper_Miles_per_Gallon"
         },
         {
           "type": "formula",
-          "expr": "datum[\"center_Miles_per_Gallon\"] - datum[\"extent_Miles_per_Gallon\"]",
+          "expr": "datum['center_Miles_per_Gallon'] - datum['extent_Miles_per_Gallon']",
           "as": "lower_Miles_per_Gallon"
         },
         {
diff --git a/examples/specs/normalized/bar_grouped_errorbar_normalized.vl.json b/examples/specs/normalized/bar_grouped_errorbar_normalized.vl.json
index 8cf5b30ec2..471acc54b9 100644
--- a/examples/specs/normalized/bar_grouped_errorbar_normalized.vl.json
+++ b/examples/specs/normalized/bar_grouped_errorbar_normalized.vl.json
@@ -30,11 +30,11 @@
           "groupby": ["Cylinders", "Origin"]
         },
         {
-          "calculate": "datum[\"center_Acceleration\"] + datum[\"extent_Acceleration\"]",
+          "calculate": "datum['center_Acceleration'] + datum['extent_Acceleration']",
           "as": "upper_Acceleration"
         },
         {
-          "calculate": "datum[\"center_Acceleration\"] - datum[\"extent_Acceleration\"]",
+          "calculate": "datum['center_Acceleration'] - datum['extent_Acceleration']",
           "as": "lower_Acceleration"
         }
       ],
diff --git a/examples/specs/normalized/boxplot_1D_horizontal_custom_mark_normalized.vl.json b/examples/specs/normalized/boxplot_1D_horizontal_custom_mark_normalized.vl.json
index fecd2fe25e..20878bf29d 100644
--- a/examples/specs/normalized/boxplot_1D_horizontal_custom_mark_normalized.vl.json
+++ b/examples/specs/normalized/boxplot_1D_horizontal_custom_mark_normalized.vl.json
@@ -25,7 +25,7 @@
         {
           "transform": [
             {
-              "filter": "(datum[\"Body Mass (g)\"] < datum[\"lower_box_Body Mass (g)\"] - 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"])) || (datum[\"Body Mass (g)\"] > datum[\"upper_box_Body Mass (g)\"] + 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"]))"
+              "filter": "(datum['Body Mass (g)'] < datum['lower_box_Body Mass (g)'] - 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)'])) || (datum['Body Mass (g)'] > datum['upper_box_Body Mass (g)'] + 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)']))"
             }
           ],
           "mark": {"type": "point", "style": "boxplot-outliers"},
@@ -41,7 +41,7 @@
         {
           "transform": [
             {
-              "filter": "(datum[\"lower_box_Body Mass (g)\"] - 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"]) <= datum[\"Body Mass (g)\"]) && (datum[\"Body Mass (g)\"] <= datum[\"upper_box_Body Mass (g)\"] + 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"]))"
+              "filter": "(datum['lower_box_Body Mass (g)'] - 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)']) <= datum['Body Mass (g)']) && (datum['Body Mass (g)'] <= datum['upper_box_Body Mass (g)'] + 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)']))"
             },
             {
               "aggregate": [
diff --git a/examples/specs/normalized/boxplot_1D_horizontal_explicit_normalized.vl.json b/examples/specs/normalized/boxplot_1D_horizontal_explicit_normalized.vl.json
index 3346ac339f..78ff30b9e1 100644
--- a/examples/specs/normalized/boxplot_1D_horizontal_explicit_normalized.vl.json
+++ b/examples/specs/normalized/boxplot_1D_horizontal_explicit_normalized.vl.json
@@ -25,7 +25,7 @@
         {
           "transform": [
             {
-              "filter": "(datum[\"Body Mass (g)\"] < datum[\"lower_box_Body Mass (g)\"] - 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"])) || (datum[\"Body Mass (g)\"] > datum[\"upper_box_Body Mass (g)\"] + 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"]))"
+              "filter": "(datum['Body Mass (g)'] < datum['lower_box_Body Mass (g)'] - 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)'])) || (datum['Body Mass (g)'] > datum['upper_box_Body Mass (g)'] + 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)']))"
             }
           ],
           "mark": {"type": "point", "style": "boxplot-outliers"},
@@ -41,7 +41,7 @@
         {
           "transform": [
             {
-              "filter": "(datum[\"lower_box_Body Mass (g)\"] - 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"]) <= datum[\"Body Mass (g)\"]) && (datum[\"Body Mass (g)\"] <= datum[\"upper_box_Body Mass (g)\"] + 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"]))"
+              "filter": "(datum['lower_box_Body Mass (g)'] - 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)']) <= datum['Body Mass (g)']) && (datum['Body Mass (g)'] <= datum['upper_box_Body Mass (g)'] + 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)']))"
             },
             {
               "aggregate": [
diff --git a/examples/specs/normalized/boxplot_1D_horizontal_normalized.vl.json b/examples/specs/normalized/boxplot_1D_horizontal_normalized.vl.json
index 3346ac339f..78ff30b9e1 100644
--- a/examples/specs/normalized/boxplot_1D_horizontal_normalized.vl.json
+++ b/examples/specs/normalized/boxplot_1D_horizontal_normalized.vl.json
@@ -25,7 +25,7 @@
         {
           "transform": [
             {
-              "filter": "(datum[\"Body Mass (g)\"] < datum[\"lower_box_Body Mass (g)\"] - 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"])) || (datum[\"Body Mass (g)\"] > datum[\"upper_box_Body Mass (g)\"] + 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"]))"
+              "filter": "(datum['Body Mass (g)'] < datum['lower_box_Body Mass (g)'] - 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)'])) || (datum['Body Mass (g)'] > datum['upper_box_Body Mass (g)'] + 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)']))"
             }
           ],
           "mark": {"type": "point", "style": "boxplot-outliers"},
@@ -41,7 +41,7 @@
         {
           "transform": [
             {
-              "filter": "(datum[\"lower_box_Body Mass (g)\"] - 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"]) <= datum[\"Body Mass (g)\"]) && (datum[\"Body Mass (g)\"] <= datum[\"upper_box_Body Mass (g)\"] + 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"]))"
+              "filter": "(datum['lower_box_Body Mass (g)'] - 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)']) <= datum['Body Mass (g)']) && (datum['Body Mass (g)'] <= datum['upper_box_Body Mass (g)'] + 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)']))"
             },
             {
               "aggregate": [
diff --git a/examples/specs/normalized/boxplot_1D_invalid_normalized.vl.json b/examples/specs/normalized/boxplot_1D_invalid_normalized.vl.json
index dce2524e3d..10c7453cc5 100644
--- a/examples/specs/normalized/boxplot_1D_invalid_normalized.vl.json
+++ b/examples/specs/normalized/boxplot_1D_invalid_normalized.vl.json
@@ -25,7 +25,7 @@
         {
           "transform": [
             {
-              "filter": "(datum[\"b\"] < datum[\"lower_box_b\"] - 1.5 * (datum[\"upper_box_b\"] - datum[\"lower_box_b\"])) || (datum[\"b\"] > datum[\"upper_box_b\"] + 1.5 * (datum[\"upper_box_b\"] - datum[\"lower_box_b\"]))"
+              "filter": "(datum['b'] < datum['lower_box_b'] - 1.5 * (datum['upper_box_b'] - datum['lower_box_b'])) || (datum['b'] > datum['upper_box_b'] + 1.5 * (datum['upper_box_b'] - datum['lower_box_b']))"
             }
           ],
           "mark": {"type": "point", "style": "boxplot-outliers"},
@@ -41,7 +41,7 @@
         {
           "transform": [
             {
-              "filter": "(datum[\"lower_box_b\"] - 1.5 * (datum[\"upper_box_b\"] - datum[\"lower_box_b\"]) <= datum[\"b\"]) && (datum[\"b\"] <= datum[\"upper_box_b\"] + 1.5 * (datum[\"upper_box_b\"] - datum[\"lower_box_b\"]))"
+              "filter": "(datum['lower_box_b'] - 1.5 * (datum['upper_box_b'] - datum['lower_box_b']) <= datum['b']) && (datum['b'] <= datum['upper_box_b'] + 1.5 * (datum['upper_box_b'] - datum['lower_box_b']))"
             },
             {
               "aggregate": [
diff --git a/examples/specs/normalized/boxplot_1D_vertical_normalized.vl.json b/examples/specs/normalized/boxplot_1D_vertical_normalized.vl.json
index 6a0640cc08..2e80baef15 100644
--- a/examples/specs/normalized/boxplot_1D_vertical_normalized.vl.json
+++ b/examples/specs/normalized/boxplot_1D_vertical_normalized.vl.json
@@ -25,7 +25,7 @@
         {
           "transform": [
             {
-              "filter": "(datum[\"Body Mass (g)\"] < datum[\"lower_box_Body Mass (g)\"] - 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"])) || (datum[\"Body Mass (g)\"] > datum[\"upper_box_Body Mass (g)\"] + 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"]))"
+              "filter": "(datum['Body Mass (g)'] < datum['lower_box_Body Mass (g)'] - 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)'])) || (datum['Body Mass (g)'] > datum['upper_box_Body Mass (g)'] + 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)']))"
             }
           ],
           "mark": {"type": "point", "style": "boxplot-outliers"},
@@ -41,7 +41,7 @@
         {
           "transform": [
             {
-              "filter": "(datum[\"lower_box_Body Mass (g)\"] - 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"]) <= datum[\"Body Mass (g)\"]) && (datum[\"Body Mass (g)\"] <= datum[\"upper_box_Body Mass (g)\"] + 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"]))"
+              "filter": "(datum['lower_box_Body Mass (g)'] - 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)']) <= datum['Body Mass (g)']) && (datum['Body Mass (g)'] <= datum['upper_box_Body Mass (g)'] + 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)']))"
             },
             {
               "aggregate": [
diff --git a/examples/specs/normalized/boxplot_2D_horizontal_color_size_normalized.vl.json b/examples/specs/normalized/boxplot_2D_horizontal_color_size_normalized.vl.json
index e7c86be774..ff79852a44 100644
--- a/examples/specs/normalized/boxplot_2D_horizontal_color_size_normalized.vl.json
+++ b/examples/specs/normalized/boxplot_2D_horizontal_color_size_normalized.vl.json
@@ -25,7 +25,7 @@
         {
           "transform": [
             {
-              "filter": "(datum[\"Body Mass (g)\"] < datum[\"lower_box_Body Mass (g)\"] - 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"])) || (datum[\"Body Mass (g)\"] > datum[\"upper_box_Body Mass (g)\"] + 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"]))"
+              "filter": "(datum['Body Mass (g)'] < datum['lower_box_Body Mass (g)'] - 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)'])) || (datum['Body Mass (g)'] > datum['upper_box_Body Mass (g)'] + 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)']))"
             }
           ],
           "mark": {"type": "point", "style": "boxplot-outliers"},
@@ -43,7 +43,7 @@
         {
           "transform": [
             {
-              "filter": "(datum[\"lower_box_Body Mass (g)\"] - 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"]) <= datum[\"Body Mass (g)\"]) && (datum[\"Body Mass (g)\"] <= datum[\"upper_box_Body Mass (g)\"] + 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"]))"
+              "filter": "(datum['lower_box_Body Mass (g)'] - 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)']) <= datum['Body Mass (g)']) && (datum['Body Mass (g)'] <= datum['upper_box_Body Mass (g)'] + 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)']))"
             },
             {
               "aggregate": [
diff --git a/examples/specs/normalized/boxplot_2D_horizontal_normalized.vl.json b/examples/specs/normalized/boxplot_2D_horizontal_normalized.vl.json
index ccd9dc76e3..48e677b3b8 100644
--- a/examples/specs/normalized/boxplot_2D_horizontal_normalized.vl.json
+++ b/examples/specs/normalized/boxplot_2D_horizontal_normalized.vl.json
@@ -25,7 +25,7 @@
         {
           "transform": [
             {
-              "filter": "(datum[\"Body Mass (g)\"] < datum[\"lower_box_Body Mass (g)\"] - 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"])) || (datum[\"Body Mass (g)\"] > datum[\"upper_box_Body Mass (g)\"] + 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"]))"
+              "filter": "(datum['Body Mass (g)'] < datum['lower_box_Body Mass (g)'] - 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)'])) || (datum['Body Mass (g)'] > datum['upper_box_Body Mass (g)'] + 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)']))"
             }
           ],
           "mark": {"type": "point", "style": "boxplot-outliers"},
@@ -42,7 +42,7 @@
         {
           "transform": [
             {
-              "filter": "(datum[\"lower_box_Body Mass (g)\"] - 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"]) <= datum[\"Body Mass (g)\"]) && (datum[\"Body Mass (g)\"] <= datum[\"upper_box_Body Mass (g)\"] + 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"]))"
+              "filter": "(datum['lower_box_Body Mass (g)'] - 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)']) <= datum['Body Mass (g)']) && (datum['Body Mass (g)'] <= datum['upper_box_Body Mass (g)'] + 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)']))"
             },
             {
               "aggregate": [
diff --git a/examples/specs/normalized/boxplot_2D_vertical_normalized.vl.json b/examples/specs/normalized/boxplot_2D_vertical_normalized.vl.json
index 6acebbfc1b..608b1218bd 100644
--- a/examples/specs/normalized/boxplot_2D_vertical_normalized.vl.json
+++ b/examples/specs/normalized/boxplot_2D_vertical_normalized.vl.json
@@ -25,7 +25,7 @@
         {
           "transform": [
             {
-              "filter": "(datum[\"Body Mass (g)\"] < datum[\"lower_box_Body Mass (g)\"] - 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"])) || (datum[\"Body Mass (g)\"] > datum[\"upper_box_Body Mass (g)\"] + 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"]))"
+              "filter": "(datum['Body Mass (g)'] < datum['lower_box_Body Mass (g)'] - 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)'])) || (datum['Body Mass (g)'] > datum['upper_box_Body Mass (g)'] + 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)']))"
             }
           ],
           "mark": {"type": "point", "style": "boxplot-outliers"},
@@ -43,7 +43,7 @@
         {
           "transform": [
             {
-              "filter": "(datum[\"lower_box_Body Mass (g)\"] - 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"]) <= datum[\"Body Mass (g)\"]) && (datum[\"Body Mass (g)\"] <= datum[\"upper_box_Body Mass (g)\"] + 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"]))"
+              "filter": "(datum['lower_box_Body Mass (g)'] - 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)']) <= datum['Body Mass (g)']) && (datum['Body Mass (g)'] <= datum['upper_box_Body Mass (g)'] + 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)']))"
             },
             {
               "aggregate": [
diff --git a/examples/specs/normalized/boxplot_2D_vertical_single_per_group_color_normalized.vl.json b/examples/specs/normalized/boxplot_2D_vertical_single_per_group_color_normalized.vl.json
index f33ab5ebd9..361caabf32 100644
--- a/examples/specs/normalized/boxplot_2D_vertical_single_per_group_color_normalized.vl.json
+++ b/examples/specs/normalized/boxplot_2D_vertical_single_per_group_color_normalized.vl.json
@@ -19,7 +19,7 @@
         {
           "transform": [
             {
-              "filter": "(datum[\"b\"] < datum[\"lower_box_b\"] - 1.5 * (datum[\"upper_box_b\"] - datum[\"lower_box_b\"])) || (datum[\"b\"] > datum[\"upper_box_b\"] + 1.5 * (datum[\"upper_box_b\"] - datum[\"lower_box_b\"]))"
+              "filter": "(datum['b'] < datum['lower_box_b'] - 1.5 * (datum['upper_box_b'] - datum['lower_box_b'])) || (datum['b'] > datum['upper_box_b'] + 1.5 * (datum['upper_box_b'] - datum['lower_box_b']))"
             }
           ],
           "mark": {"type": "point", "style": "boxplot-outliers"},
@@ -32,7 +32,7 @@
         {
           "transform": [
             {
-              "filter": "(datum[\"lower_box_b\"] - 1.5 * (datum[\"upper_box_b\"] - datum[\"lower_box_b\"]) <= datum[\"b\"]) && (datum[\"b\"] <= datum[\"upper_box_b\"] + 1.5 * (datum[\"upper_box_b\"] - datum[\"lower_box_b\"]))"
+              "filter": "(datum['lower_box_b'] - 1.5 * (datum['upper_box_b'] - datum['lower_box_b']) <= datum['b']) && (datum['b'] <= datum['upper_box_b'] + 1.5 * (datum['upper_box_b'] - datum['lower_box_b']))"
             },
             {
               "aggregate": [
diff --git a/examples/specs/normalized/boxplot_2D_vertical_single_per_group_normalized.vl.json b/examples/specs/normalized/boxplot_2D_vertical_single_per_group_normalized.vl.json
index dc2969b67a..98086e3af3 100644
--- a/examples/specs/normalized/boxplot_2D_vertical_single_per_group_normalized.vl.json
+++ b/examples/specs/normalized/boxplot_2D_vertical_single_per_group_normalized.vl.json
@@ -19,7 +19,7 @@
         {
           "transform": [
             {
-              "filter": "(datum[\"b\"] < datum[\"lower_box_b\"] - 1.5 * (datum[\"upper_box_b\"] - datum[\"lower_box_b\"])) || (datum[\"b\"] > datum[\"upper_box_b\"] + 1.5 * (datum[\"upper_box_b\"] - datum[\"lower_box_b\"]))"
+              "filter": "(datum['b'] < datum['lower_box_b'] - 1.5 * (datum['upper_box_b'] - datum['lower_box_b'])) || (datum['b'] > datum['upper_box_b'] + 1.5 * (datum['upper_box_b'] - datum['lower_box_b']))"
             }
           ],
           "mark": {"type": "point", "style": "boxplot-outliers"},
@@ -31,7 +31,7 @@
         {
           "transform": [
             {
-              "filter": "(datum[\"lower_box_b\"] - 1.5 * (datum[\"upper_box_b\"] - datum[\"lower_box_b\"]) <= datum[\"b\"]) && (datum[\"b\"] <= datum[\"upper_box_b\"] + 1.5 * (datum[\"upper_box_b\"] - datum[\"lower_box_b\"]))"
+              "filter": "(datum['lower_box_b'] - 1.5 * (datum['upper_box_b'] - datum['lower_box_b']) <= datum['b']) && (datum['b'] <= datum['upper_box_b'] + 1.5 * (datum['upper_box_b'] - datum['lower_box_b']))"
             },
             {
               "aggregate": [
diff --git a/examples/specs/normalized/boxplot_groupped_normalized.vl.json b/examples/specs/normalized/boxplot_groupped_normalized.vl.json
index 668b0f1257..49ca64b4c4 100644
--- a/examples/specs/normalized/boxplot_groupped_normalized.vl.json
+++ b/examples/specs/normalized/boxplot_groupped_normalized.vl.json
@@ -25,7 +25,7 @@
         {
           "transform": [
             {
-              "filter": "(datum[\"Acceleration\"] < datum[\"lower_box_Acceleration\"] - 1.5 * (datum[\"upper_box_Acceleration\"] - datum[\"lower_box_Acceleration\"])) || (datum[\"Acceleration\"] > datum[\"upper_box_Acceleration\"] + 1.5 * (datum[\"upper_box_Acceleration\"] - datum[\"lower_box_Acceleration\"]))"
+              "filter": "(datum['Acceleration'] < datum['lower_box_Acceleration'] - 1.5 * (datum['upper_box_Acceleration'] - datum['lower_box_Acceleration'])) || (datum['Acceleration'] > datum['upper_box_Acceleration'] + 1.5 * (datum['upper_box_Acceleration'] - datum['lower_box_Acceleration']))"
             }
           ],
           "mark": {"type": "point", "style": "boxplot-outliers"},
@@ -43,7 +43,7 @@
         {
           "transform": [
             {
-              "filter": "(datum[\"lower_box_Acceleration\"] - 1.5 * (datum[\"upper_box_Acceleration\"] - datum[\"lower_box_Acceleration\"]) <= datum[\"Acceleration\"]) && (datum[\"Acceleration\"] <= datum[\"upper_box_Acceleration\"] + 1.5 * (datum[\"upper_box_Acceleration\"] - datum[\"lower_box_Acceleration\"]))"
+              "filter": "(datum['lower_box_Acceleration'] - 1.5 * (datum['upper_box_Acceleration'] - datum['lower_box_Acceleration']) <= datum['Acceleration']) && (datum['Acceleration'] <= datum['upper_box_Acceleration'] + 1.5 * (datum['upper_box_Acceleration'] - datum['lower_box_Acceleration']))"
             },
             {
               "aggregate": [
diff --git a/examples/specs/normalized/boxplot_tooltip_aggregate_normalized.vl.json b/examples/specs/normalized/boxplot_tooltip_aggregate_normalized.vl.json
index 3180a7c526..a0e818aa29 100644
--- a/examples/specs/normalized/boxplot_tooltip_aggregate_normalized.vl.json
+++ b/examples/specs/normalized/boxplot_tooltip_aggregate_normalized.vl.json
@@ -25,7 +25,7 @@
         {
           "transform": [
             {
-              "filter": "(datum[\"Body Mass (g)\"] < datum[\"lower_box_Body Mass (g)\"] - 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"])) || (datum[\"Body Mass (g)\"] > datum[\"upper_box_Body Mass (g)\"] + 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"]))"
+              "filter": "(datum['Body Mass (g)'] < datum['lower_box_Body Mass (g)'] - 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)'])) || (datum['Body Mass (g)'] > datum['upper_box_Body Mass (g)'] + 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)']))"
             }
           ],
           "mark": {"type": "point", "style": "boxplot-outliers"},
@@ -42,7 +42,7 @@
         {
           "transform": [
             {
-              "filter": "(datum[\"lower_box_Body Mass (g)\"] - 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"]) <= datum[\"Body Mass (g)\"]) && (datum[\"Body Mass (g)\"] <= datum[\"upper_box_Body Mass (g)\"] + 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"]))"
+              "filter": "(datum['lower_box_Body Mass (g)'] - 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)']) <= datum['Body Mass (g)']) && (datum['Body Mass (g)'] <= datum['upper_box_Body Mass (g)'] + 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)']))"
             },
             {
               "aggregate": [
diff --git a/examples/specs/normalized/boxplot_tooltip_not_aggregate_normalized.vl.json b/examples/specs/normalized/boxplot_tooltip_not_aggregate_normalized.vl.json
index e5259d3b63..263bfb9a8a 100644
--- a/examples/specs/normalized/boxplot_tooltip_not_aggregate_normalized.vl.json
+++ b/examples/specs/normalized/boxplot_tooltip_not_aggregate_normalized.vl.json
@@ -25,7 +25,7 @@
         {
           "transform": [
             {
-              "filter": "(datum[\"Body Mass (g)\"] < datum[\"lower_box_Body Mass (g)\"] - 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"])) || (datum[\"Body Mass (g)\"] > datum[\"upper_box_Body Mass (g)\"] + 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"]))"
+              "filter": "(datum['Body Mass (g)'] < datum['lower_box_Body Mass (g)'] - 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)'])) || (datum['Body Mass (g)'] > datum['upper_box_Body Mass (g)'] + 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)']))"
             }
           ],
           "mark": {"type": "point", "style": "boxplot-outliers"},
@@ -43,7 +43,7 @@
         {
           "transform": [
             {
-              "filter": "(datum[\"lower_box_Body Mass (g)\"] - 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"]) <= datum[\"Body Mass (g)\"]) && (datum[\"Body Mass (g)\"] <= datum[\"upper_box_Body Mass (g)\"] + 1.5 * (datum[\"upper_box_Body Mass (g)\"] - datum[\"lower_box_Body Mass (g)\"]))"
+              "filter": "(datum['lower_box_Body Mass (g)'] - 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)']) <= datum['Body Mass (g)']) && (datum['Body Mass (g)'] <= datum['upper_box_Body Mass (g)'] + 1.5 * (datum['upper_box_Body Mass (g)'] - datum['lower_box_Body Mass (g)']))"
             },
             {
               "aggregate": [
diff --git a/examples/specs/normalized/errorband_tooltip_normalized.vl.json b/examples/specs/normalized/errorband_tooltip_normalized.vl.json
index c2fa37de1d..f1467540cc 100644
--- a/examples/specs/normalized/errorband_tooltip_normalized.vl.json
+++ b/examples/specs/normalized/errorband_tooltip_normalized.vl.json
@@ -19,11 +19,11 @@
       "groupby": ["year_Year", "Miles_per_Gallon"]
     },
     {
-      "calculate": "datum[\"center_Miles_per_Gallon\"] + datum[\"extent_Miles_per_Gallon\"]",
+      "calculate": "datum['center_Miles_per_Gallon'] + datum['extent_Miles_per_Gallon']",
       "as": "upper_Miles_per_Gallon"
     },
     {
-      "calculate": "datum[\"center_Miles_per_Gallon\"] - datum[\"extent_Miles_per_Gallon\"]",
+      "calculate": "datum['center_Miles_per_Gallon'] - datum['extent_Miles_per_Gallon']",
       "as": "lower_Miles_per_Gallon"
     }
   ],
diff --git a/examples/specs/normalized/errorbar_tooltip_normalized.vl.json b/examples/specs/normalized/errorbar_tooltip_normalized.vl.json
index 996a16f38a..4e83ecd3c1 100644
--- a/examples/specs/normalized/errorbar_tooltip_normalized.vl.json
+++ b/examples/specs/normalized/errorbar_tooltip_normalized.vl.json
@@ -10,11 +10,11 @@
       "groupby": ["variety", "variety"]
     },
     {
-      "calculate": "datum[\"center_yield\"] + datum[\"extent_yield\"]",
+      "calculate": "datum['center_yield'] + datum['extent_yield']",
       "as": "upper_yield"
     },
     {
-      "calculate": "datum[\"center_yield\"] - datum[\"extent_yield\"]",
+      "calculate": "datum['center_yield'] - datum['extent_yield']",
       "as": "lower_yield"
     }
   ],
diff --git a/examples/specs/normalized/layer_boxplot_circle_normalized.vl.json b/examples/specs/normalized/layer_boxplot_circle_normalized.vl.json
index 4b9038e964..441df1830f 100644
--- a/examples/specs/normalized/layer_boxplot_circle_normalized.vl.json
+++ b/examples/specs/normalized/layer_boxplot_circle_normalized.vl.json
@@ -16,7 +16,7 @@
               "groupby": ["age"]
             },
             {
-              "filter": "(datum[\"lower_box_people\"] - 1.5 * (datum[\"upper_box_people\"] - datum[\"lower_box_people\"]) <= datum[\"people\"]) && (datum[\"people\"] <= datum[\"upper_box_people\"] + 1.5 * (datum[\"upper_box_people\"] - datum[\"lower_box_people\"]))"
+              "filter": "(datum['lower_box_people'] - 1.5 * (datum['upper_box_people'] - datum['lower_box_people']) <= datum['people']) && (datum['people'] <= datum['upper_box_people'] + 1.5 * (datum['upper_box_people'] - datum['lower_box_people']))"
             },
             {
               "aggregate": [
diff --git a/examples/specs/normalized/layer_line_errorband_pre_aggregated_normalized.vl.json b/examples/specs/normalized/layer_line_errorband_pre_aggregated_normalized.vl.json
index 2080ffec81..27e45fcad8 100644
--- a/examples/specs/normalized/layer_line_errorband_pre_aggregated_normalized.vl.json
+++ b/examples/specs/normalized/layer_line_errorband_pre_aggregated_normalized.vl.json
@@ -12,8 +12,8 @@
     {
       "transform": [
         {"timeUnit": {"unit": "year"}, "field": "Year", "as": "year_Year"},
-        {"calculate": "datum[\"ci0\"]", "as": "upper_ci1"},
-        {"calculate": "datum[\"ci1\"]", "as": "lower_ci1"}
+        {"calculate": "datum['ci0']", "as": "upper_ci1"},
+        {"calculate": "datum['ci1']", "as": "lower_ci1"}
       ],
       "layer": [
         {
diff --git a/examples/specs/normalized/layer_point_errorbar_1d_horizontal_normalized.vl.json b/examples/specs/normalized/layer_point_errorbar_1d_horizontal_normalized.vl.json
index 266e618a9c..79a8db1cdd 100644
--- a/examples/specs/normalized/layer_point_errorbar_1d_horizontal_normalized.vl.json
+++ b/examples/specs/normalized/layer_point_errorbar_1d_horizontal_normalized.vl.json
@@ -12,11 +12,11 @@
           "groupby": []
         },
         {
-          "calculate": "datum[\"center_yield\"] + datum[\"extent_yield\"]",
+          "calculate": "datum['center_yield'] + datum['extent_yield']",
           "as": "upper_yield"
         },
         {
-          "calculate": "datum[\"center_yield\"] - datum[\"extent_yield\"]",
+          "calculate": "datum['center_yield'] - datum['extent_yield']",
           "as": "lower_yield"
         }
       ],
diff --git a/examples/specs/normalized/layer_point_errorbar_1d_vertical_normalized.vl.json b/examples/specs/normalized/layer_point_errorbar_1d_vertical_normalized.vl.json
index 6f264919e1..1b32e8e775 100644
--- a/examples/specs/normalized/layer_point_errorbar_1d_vertical_normalized.vl.json
+++ b/examples/specs/normalized/layer_point_errorbar_1d_vertical_normalized.vl.json
@@ -12,11 +12,11 @@
           "groupby": []
         },
         {
-          "calculate": "datum[\"center_yield\"] + datum[\"extent_yield\"]",
+          "calculate": "datum['center_yield'] + datum['extent_yield']",
           "as": "upper_yield"
         },
         {
-          "calculate": "datum[\"center_yield\"] - datum[\"extent_yield\"]",
+          "calculate": "datum['center_yield'] - datum['extent_yield']",
           "as": "lower_yield"
         }
       ],
diff --git a/examples/specs/normalized/layer_point_errorbar_2d_horizontal_color_encoding_normalized.vl.json b/examples/specs/normalized/layer_point_errorbar_2d_horizontal_color_encoding_normalized.vl.json
index 413741ed78..68e2ff4f35 100644
--- a/examples/specs/normalized/layer_point_errorbar_2d_horizontal_color_encoding_normalized.vl.json
+++ b/examples/specs/normalized/layer_point_errorbar_2d_horizontal_color_encoding_normalized.vl.json
@@ -12,11 +12,11 @@
           "groupby": ["variety"]
         },
         {
-          "calculate": "datum[\"center_yield\"] + datum[\"extent_yield\"]",
+          "calculate": "datum['center_yield'] + datum['extent_yield']",
           "as": "upper_yield"
         },
         {
-          "calculate": "datum[\"center_yield\"] - datum[\"extent_yield\"]",
+          "calculate": "datum['center_yield'] - datum['extent_yield']",
           "as": "lower_yield"
         }
       ],
diff --git a/examples/specs/normalized/layer_point_errorbar_2d_horizontal_custom_ticks_normalized.vl.json b/examples/specs/normalized/layer_point_errorbar_2d_horizontal_custom_ticks_normalized.vl.json
index 7796c08b99..b396742d7f 100644
--- a/examples/specs/normalized/layer_point_errorbar_2d_horizontal_custom_ticks_normalized.vl.json
+++ b/examples/specs/normalized/layer_point_errorbar_2d_horizontal_custom_ticks_normalized.vl.json
@@ -12,11 +12,11 @@
           "groupby": ["variety"]
         },
         {
-          "calculate": "datum[\"center_yield\"] + datum[\"extent_yield\"]",
+          "calculate": "datum['center_yield'] + datum['extent_yield']",
           "as": "upper_yield"
         },
         {
-          "calculate": "datum[\"center_yield\"] - datum[\"extent_yield\"]",
+          "calculate": "datum['center_yield'] - datum['extent_yield']",
           "as": "lower_yield"
         }
       ],
diff --git a/examples/specs/normalized/layer_point_errorbar_2d_horizontal_normalized.vl.json b/examples/specs/normalized/layer_point_errorbar_2d_horizontal_normalized.vl.json
index e7e82a6c8b..0b752657a1 100644
--- a/examples/specs/normalized/layer_point_errorbar_2d_horizontal_normalized.vl.json
+++ b/examples/specs/normalized/layer_point_errorbar_2d_horizontal_normalized.vl.json
@@ -12,11 +12,11 @@
           "groupby": ["variety"]
         },
         {
-          "calculate": "datum[\"center_yield\"] + datum[\"extent_yield\"]",
+          "calculate": "datum['center_yield'] + datum['extent_yield']",
           "as": "upper_yield"
         },
         {
-          "calculate": "datum[\"center_yield\"] - datum[\"extent_yield\"]",
+          "calculate": "datum['center_yield'] - datum['extent_yield']",
           "as": "lower_yield"
         }
       ],
diff --git a/examples/specs/normalized/layer_point_errorbar_2d_horizontal_stdev_normalized.vl.json b/examples/specs/normalized/layer_point_errorbar_2d_horizontal_stdev_normalized.vl.json
index 64d6a61ffb..d1545ba5c1 100644
--- a/examples/specs/normalized/layer_point_errorbar_2d_horizontal_stdev_normalized.vl.json
+++ b/examples/specs/normalized/layer_point_errorbar_2d_horizontal_stdev_normalized.vl.json
@@ -12,11 +12,11 @@
           "groupby": ["variety"]
         },
         {
-          "calculate": "datum[\"center_yield\"] + datum[\"extent_yield\"]",
+          "calculate": "datum['center_yield'] + datum['extent_yield']",
           "as": "upper_yield"
         },
         {
-          "calculate": "datum[\"center_yield\"] - datum[\"extent_yield\"]",
+          "calculate": "datum['center_yield'] - datum['extent_yield']",
           "as": "lower_yield"
         }
       ],
diff --git a/examples/specs/normalized/layer_point_errorbar_2d_vertical_normalized.vl.json b/examples/specs/normalized/layer_point_errorbar_2d_vertical_normalized.vl.json
index 4bf3e2d533..6dd61c4f79 100644
--- a/examples/specs/normalized/layer_point_errorbar_2d_vertical_normalized.vl.json
+++ b/examples/specs/normalized/layer_point_errorbar_2d_vertical_normalized.vl.json
@@ -12,11 +12,11 @@
           "groupby": ["variety"]
         },
         {
-          "calculate": "datum[\"center_yield\"] + datum[\"extent_yield\"]",
+          "calculate": "datum['center_yield'] + datum['extent_yield']",
           "as": "upper_yield"
         },
         {
-          "calculate": "datum[\"center_yield\"] - datum[\"extent_yield\"]",
+          "calculate": "datum['center_yield'] - datum['extent_yield']",
           "as": "lower_yield"
         }
       ],
diff --git a/examples/specs/normalized/layer_point_errorbar_pre_aggregated_asymmetric_error_normalized.vl.json b/examples/specs/normalized/layer_point_errorbar_pre_aggregated_asymmetric_error_normalized.vl.json
index acd94f8a26..8735611767 100644
--- a/examples/specs/normalized/layer_point_errorbar_pre_aggregated_asymmetric_error_normalized.vl.json
+++ b/examples/specs/normalized/layer_point_errorbar_pre_aggregated_asymmetric_error_normalized.vl.json
@@ -32,11 +32,11 @@
     {
       "transform": [
         {
-          "calculate": "datum[\"yield_center\"] + datum[\"yield_error\"]",
+          "calculate": "datum['yield_center'] + datum['yield_error']",
           "as": "upper_yield_center"
         },
         {
-          "calculate": "datum[\"yield_center\"] + datum[\"yield_error2\"]",
+          "calculate": "datum['yield_center'] + datum['yield_error2']",
           "as": "lower_yield_center"
         }
       ],
diff --git a/examples/specs/normalized/layer_point_errorbar_pre_aggregated_symmetric_error_normalized.vl.json b/examples/specs/normalized/layer_point_errorbar_pre_aggregated_symmetric_error_normalized.vl.json
index fa14822061..e480976649 100644
--- a/examples/specs/normalized/layer_point_errorbar_pre_aggregated_symmetric_error_normalized.vl.json
+++ b/examples/specs/normalized/layer_point_errorbar_pre_aggregated_symmetric_error_normalized.vl.json
@@ -12,11 +12,11 @@
     {
       "transform": [
         {
-          "calculate": "datum[\"yield_center\"] + datum[\"yield_error\"]",
+          "calculate": "datum['yield_center'] + datum['yield_error']",
           "as": "upper_yield_center"
         },
         {
-          "calculate": "datum[\"yield_center\"] - datum[\"yield_error\"]",
+          "calculate": "datum['yield_center'] - datum['yield_error']",
           "as": "lower_yield_center"
         }
       ],
diff --git a/examples/specs/normalized/layer_point_errorbar_pre_aggregated_upper_lower_normalized.vl.json b/examples/specs/normalized/layer_point_errorbar_pre_aggregated_upper_lower_normalized.vl.json
index 7ca7d505c8..ddff34cb89 100644
--- a/examples/specs/normalized/layer_point_errorbar_pre_aggregated_upper_lower_normalized.vl.json
+++ b/examples/specs/normalized/layer_point_errorbar_pre_aggregated_upper_lower_normalized.vl.json
@@ -31,8 +31,8 @@
   "layer": [
     {
       "transform": [
-        {"calculate": "datum[\"lower_yield\"]", "as": "upper_upper_yield"},
-        {"calculate": "datum[\"upper_yield\"]", "as": "lower_upper_yield"}
+        {"calculate": "datum['lower_yield']", "as": "upper_upper_yield"},
+        {"calculate": "datum['upper_yield']", "as": "lower_upper_yield"}
       ],
       "mark": {
         "type": "rule",
diff --git a/examples/specs/normalized/layer_point_errorbar_stdev_normalized.vl.json b/examples/specs/normalized/layer_point_errorbar_stdev_normalized.vl.json
index b17ca84dad..15d232c9e6 100644
--- a/examples/specs/normalized/layer_point_errorbar_stdev_normalized.vl.json
+++ b/examples/specs/normalized/layer_point_errorbar_stdev_normalized.vl.json
@@ -26,11 +26,11 @@
           "groupby": ["variety"]
         },
         {
-          "calculate": "datum[\"center_yield\"] + datum[\"extent_yield\"]",
+          "calculate": "datum['center_yield'] + datum['extent_yield']",
           "as": "upper_yield"
         },
         {
-          "calculate": "datum[\"center_yield\"] - datum[\"extent_yield\"]",
+          "calculate": "datum['center_yield'] - datum['extent_yield']",
           "as": "lower_yield"
         }
       ],
diff --git a/examples/specs/normalized/layer_scatter_errorband_1D_stdev_global_mean_normalized.vl.json b/examples/specs/normalized/layer_scatter_errorband_1D_stdev_global_mean_normalized.vl.json
index 67cb4323af..4e990e49ad 100644
--- a/examples/specs/normalized/layer_scatter_errorband_1D_stdev_global_mean_normalized.vl.json
+++ b/examples/specs/normalized/layer_scatter_errorband_1D_stdev_global_mean_normalized.vl.json
@@ -28,11 +28,11 @@
           "groupby": []
         },
         {
-          "calculate": "datum[\"center_Miles_per_Gallon\"] + datum[\"extent_Miles_per_Gallon\"]",
+          "calculate": "datum['center_Miles_per_Gallon'] + datum['extent_Miles_per_Gallon']",
           "as": "upper_Miles_per_Gallon"
         },
         {
-          "calculate": "datum[\"center_Miles_per_Gallon\"] - datum[\"extent_Miles_per_Gallon\"]",
+          "calculate": "datum['center_Miles_per_Gallon'] - datum['extent_Miles_per_Gallon']",
           "as": "lower_Miles_per_Gallon"
         }
       ],
diff --git a/examples/specs/normalized/layer_scatter_errorband_1d_stdev_normalized.vl.json b/examples/specs/normalized/layer_scatter_errorband_1d_stdev_normalized.vl.json
index a8d3ee6382..f4791a049c 100644
--- a/examples/specs/normalized/layer_scatter_errorband_1d_stdev_normalized.vl.json
+++ b/examples/specs/normalized/layer_scatter_errorband_1d_stdev_normalized.vl.json
@@ -27,11 +27,11 @@
           "groupby": []
         },
         {
-          "calculate": "datum[\"center_Miles_per_Gallon\"] + datum[\"extent_Miles_per_Gallon\"]",
+          "calculate": "datum['center_Miles_per_Gallon'] + datum['extent_Miles_per_Gallon']",
           "as": "upper_Miles_per_Gallon"
         },
         {
-          "calculate": "datum[\"center_Miles_per_Gallon\"] - datum[\"extent_Miles_per_Gallon\"]",
+          "calculate": "datum['center_Miles_per_Gallon'] - datum['extent_Miles_per_Gallon']",
           "as": "lower_Miles_per_Gallon"
         }
       ],
diff --git a/src/compile/data/timeunit.ts b/src/compile/data/timeunit.ts
index 7e4bda8b49..2b79cd3ae7 100644
--- a/src/compile/data/timeunit.ts
+++ b/src/compile/data/timeunit.ts
@@ -10,7 +10,16 @@ import {
   normalizeTimeUnit
 } from '../../timeunit';
 import {TimeUnitTransform} from '../../transform';
-import {Dict, duplicate, entries, hash, isEmpty, replacePathInField, vals} from '../../util';
+import {
+  accessWithDatumToUnescapedPath,
+  Dict,
+  duplicate,
+  entries,
+  hash,
+  isEmpty,
+  replacePathInField,
+  vals
+} from '../../util';
 import {ModelWithField, isUnitModel} from '../model';
 import {DataFlowNode} from './dataflow';
 import {isRectBasedMark} from '../../mark';
@@ -218,7 +227,7 @@ function offsetExpr({timeUnit, field, reverse}: {timeUnit: TimeUnitParams; field
   const smallestUnit = getSmallestTimeUnitPart(unit);
   const {part, step} = getDateTimePartAndStep(smallestUnit, timeUnit.step);
   const offsetFn = utc ? 'utcOffset' : 'timeOffset';
-  const expr = `${offsetFn}('${part}', datum['${field}'], ${reverse ? -step : step})`;
+  const expr = `${offsetFn}('${part}', ${accessWithDatumToUnescapedPath(field)}, ${reverse ? -step : step})`;
   return expr;
 }
 
@@ -228,8 +237,8 @@ function offsetedRectFormulas(
   timeUnit: TimeUnitParams
 ): VgFormulaTransform[] {
   if (rectBandPosition !== undefined && rectBandPosition !== 0.5) {
-    const startExpr = `datum['${startField}']`;
-    const endExpr = `datum['${endField}']`;
+    const startExpr = accessWithDatumToUnescapedPath(startField);
+    const endExpr = accessWithDatumToUnescapedPath(endField);
     return [
       {
         type: 'formula',
diff --git a/src/compositemark/boxplot.ts b/src/compositemark/boxplot.ts
index b11df271d8..15c4040508 100644
--- a/src/compositemark/boxplot.ts
+++ b/src/compositemark/boxplot.ts
@@ -9,7 +9,7 @@ import {MarkInvalidMixins} from '../invalid';
 import {NormalizerParams} from '../normalize';
 import {GenericUnitSpec, NormalizedLayerSpec, NormalizedUnitSpec} from '../spec';
 import {AggregatedFieldDef, CalculateTransform, JoinAggregateTransform, Transform} from '../transform';
-import {isEmpty, omit, removePathFromField} from '../util';
+import {accessWithDatumToUnescapedPath, isEmpty, omit, removePathFromField} from '../util';
 import {CompositeMarkNormalizer} from './base';
 import {
   compositeMarkContinuousAxis,
@@ -143,7 +143,7 @@ export function normalizeBoxPlot(
     ...(size ? {size} : {}),
     color: {
       condition: {
-        test: `datum['lower_box_${continuousAxisChannelDef.field}'] >= datum['upper_box_${continuousAxisChannelDef.field}']`,
+        test: `${accessWithDatumToUnescapedPath(`lower_box_${continuousAxisChannelDef.field}`)} >= ${accessWithDatumToUnescapedPath(`upper_box_${continuousAxisChannelDef.field}`)}`,
         ...(color || {value: defaultBoxColor})
       }
     }
@@ -249,12 +249,12 @@ export function normalizeBoxPlot(
 
   // Tukey Box Plot
 
-  const lowerBoxExpr = `datum["lower_box_${continuousAxisChannelDef.field}"]`;
-  const upperBoxExpr = `datum["upper_box_${continuousAxisChannelDef.field}"]`;
+  const lowerBoxExpr = accessWithDatumToUnescapedPath(`lower_box_${continuousAxisChannelDef.field}`);
+  const upperBoxExpr = accessWithDatumToUnescapedPath(`upper_box_${continuousAxisChannelDef.field}`);
   const iqrExpr = `(${upperBoxExpr} - ${lowerBoxExpr})`;
   const lowerWhiskerExpr = `${lowerBoxExpr} - ${extent} * ${iqrExpr}`;
   const upperWhiskerExpr = `${upperBoxExpr} + ${extent} * ${iqrExpr}`;
-  const fieldExpr = `datum["${continuousAxisChannelDef.field}"]`;
+  const fieldExpr = accessWithDatumToUnescapedPath(continuousAxisChannelDef.field);
 
   const joinaggregateTransform: JoinAggregateTransform = {
     joinaggregate: boxParamsQuartiles(continuousAxisChannelDef.field),
@@ -399,15 +399,15 @@ function boxParams(
       : [
           // This is for the  original k-IQR, which we do not expose
           {
-            calculate: `datum["upper_box_${aliasedFieldName}"] - datum["lower_box_${aliasedFieldName}"]`,
+            calculate: `${accessWithDatumToUnescapedPath(`upper_box_${aliasedFieldName}`)} - ${accessWithDatumToUnescapedPath(`lower_box_${aliasedFieldName}`)}`,
             as: `iqr_${aliasedFieldName}`
           },
           {
-            calculate: `min(datum["upper_box_${aliasedFieldName}"] + datum["iqr_${aliasedFieldName}"] * ${extent}, datum["max_${aliasedFieldName}"])`,
+            calculate: `min(${accessWithDatumToUnescapedPath(`upper_box_${aliasedFieldName}`)} + ${accessWithDatumToUnescapedPath(`iqr_${aliasedFieldName}`)} * ${extent}, ${accessWithDatumToUnescapedPath(`max_${aliasedFieldName}`)})`,
             as: `upper_whisker_${aliasedFieldName}`
           },
           {
-            calculate: `max(datum["lower_box_${aliasedFieldName}"] - datum["iqr_${aliasedFieldName}"] * ${extent}, datum["min_${aliasedFieldName}"])`,
+            calculate: `max(${accessWithDatumToUnescapedPath(`lower_box_${aliasedFieldName}`)} - ${accessWithDatumToUnescapedPath(`iqr_${aliasedFieldName}`)} * ${extent}, ${accessWithDatumToUnescapedPath(`min_${aliasedFieldName}`)})`,
             as: `lower_whisker_${aliasedFieldName}`
           }
         ];
diff --git a/src/compositemark/errorbar.ts b/src/compositemark/errorbar.ts
index f72a1f32d8..a7ac09b576 100644
--- a/src/compositemark/errorbar.ts
+++ b/src/compositemark/errorbar.ts
@@ -21,7 +21,7 @@ import {Step} from '../spec/base';
 import {NormalizedUnitSpec} from '../spec/unit';
 import {TitleParams} from '../title';
 import {AggregatedFieldDef, CalculateTransform, Transform} from '../transform';
-import {replaceAll, titleCase} from '../util';
+import {accessWithDatumToUnescapedPath, replaceAll, titleCase} from '../util';
 import {CompositeMarkNormalizer} from './base';
 import {
   compositeMarkContinuousAxis,
@@ -464,11 +464,11 @@ function errorBarAggregationAndCalculation<
 
       postAggregateCalculates = [
         {
-          calculate: `datum["center_${continuousFieldName}"] + datum["extent_${continuousFieldName}"]`,
+          calculate: `${accessWithDatumToUnescapedPath(`center_${continuousFieldName}`)} + ${accessWithDatumToUnescapedPath(`extent_${continuousFieldName}`)}`,
           as: `upper_${continuousFieldName}`
         },
         {
-          calculate: `datum["center_${continuousFieldName}"] - datum["extent_${continuousFieldName}"]`,
+          calculate: `${accessWithDatumToUnescapedPath(`center_${continuousFieldName}`)} - ${accessWithDatumToUnescapedPath(`extent_${continuousFieldName}`)}`,
           as: `lower_${continuousFieldName}`
         }
       ];
@@ -528,26 +528,29 @@ function errorBarAggregationAndCalculation<
     if (inputType === 'aggregated-upper-lower') {
       tooltipSummary = [];
       postAggregateCalculates = [
-        {calculate: `datum["${continuousAxisChannelDef2.field}"]`, as: `upper_${continuousFieldName}`},
-        {calculate: `datum["${continuousFieldName}"]`, as: `lower_${continuousFieldName}`}
+        {
+          calculate: accessWithDatumToUnescapedPath(continuousAxisChannelDef2.field),
+          as: `upper_${continuousFieldName}`
+        },
+        {calculate: accessWithDatumToUnescapedPath(continuousFieldName), as: `lower_${continuousFieldName}`}
       ];
     } else if (inputType === 'aggregated-error') {
       tooltipSummary = [{fieldPrefix: '', titlePrefix: continuousFieldName}];
       postAggregateCalculates = [
         {
-          calculate: `datum["${continuousFieldName}"] + datum["${continuousAxisChannelDefError.field}"]`,
+          calculate: `${accessWithDatumToUnescapedPath(continuousFieldName)} + ${accessWithDatumToUnescapedPath(continuousAxisChannelDefError.field)}`,
           as: `upper_${continuousFieldName}`
         }
       ];
 
       if (continuousAxisChannelDefError2) {
         postAggregateCalculates.push({
-          calculate: `datum["${continuousFieldName}"] + datum["${continuousAxisChannelDefError2.field}"]`,
+          calculate: `${accessWithDatumToUnescapedPath(continuousFieldName)} + ${accessWithDatumToUnescapedPath(continuousAxisChannelDefError2.field)}`,
           as: `lower_${continuousFieldName}`
         });
       } else {
         postAggregateCalculates.push({
-          calculate: `datum["${continuousFieldName}"] - datum["${continuousAxisChannelDefError.field}"]`,
+          calculate: `${accessWithDatumToUnescapedPath(continuousFieldName)} - ${accessWithDatumToUnescapedPath(continuousAxisChannelDefError.field)}`,
           as: `lower_${continuousFieldName}`
         });
       }
@@ -556,7 +559,7 @@ function errorBarAggregationAndCalculation<
     for (const postAggregateCalculate of postAggregateCalculates) {
       tooltipSummary.push({
         fieldPrefix: postAggregateCalculate.as.substring(0, 6),
-        titlePrefix: replaceAll(replaceAll(postAggregateCalculate.calculate, 'datum["', ''), '"]', '')
+        titlePrefix: replaceAll(replaceAll(postAggregateCalculate.calculate, "datum['", ''), "']", '')
       });
     }
   }
diff --git a/src/util.ts b/src/util.ts
index 5159e1fed0..8c8be120fd 100644
--- a/src/util.ts
+++ b/src/util.ts
@@ -293,6 +293,23 @@ export function flatAccessWithDatum(path: string, datum: 'datum' | 'parent' | 'd
   return `${datum}[${stringValue(splitAccessPath(path).join('.'))}]`;
 }
 
+/**
+ * Return access with datum to **an unescaped path**.
+ *
+ * ```ts
+ * console.log(accessWithDatumToUnescapedPath("vega's favorite"))
+ * // "datum['vega\\'s favorite']"
+ * ```
+ *
+ * @param path The unescaped path name. E.g., `"a.b"`, `"vega's favorite"`. (Note
+ * that the field defs take escaped strings like `"a\\.b"`, `"vega\\'s favorite"`,
+ * but this function is for the unescaped field/path)
+ */
+export function accessWithDatumToUnescapedPath(unescapedPath: string) {
+  const singleQuoteEscapedPath = unescapedPath.replaceAll("'", "\\'");
+  return `datum['${singleQuoteEscapedPath}']`;
+}
+
 function escapePathAccess(string: string) {
   return string.replace(/(\[|\]|\.|'|")/g, '\\$1');
 }
diff --git a/test/compile/data/timeunit.test.ts b/test/compile/data/timeunit.test.ts
index 85cce49580..9a9e029755 100644
--- a/test/compile/data/timeunit.test.ts
+++ b/test/compile/data/timeunit.test.ts
@@ -82,6 +82,36 @@ describe('compile/data/timeunit', () => {
       ]);
     });
 
+    it('should return a unit transform for bar with bandPosition=0 and escaped field name', () => {
+      const model = parseUnitModel({
+        data: {values: []},
+        mark: 'bar',
+        encoding: {
+          x: {field: "\\'a\\'", type: 'temporal', timeUnit: 'month', bandPosition: 0}
+        }
+      });
+
+      expect(assembleFromEncoding(model)).toEqual([
+        {
+          type: 'timeunit',
+          field: "\\'a\\'",
+          as: ["month_'a'", "month_'a'_end"],
+          units: ['month']
+        },
+        {
+          type: 'formula',
+          expr: "0.5 * timeOffset('month', datum['month_\\'a\\''], -1) + 0.5 * datum['month_\\'a\\'']",
+          as: `month_'a'_${OFFSETTED_RECT_START_SUFFIX}`
+        },
+
+        {
+          type: 'formula',
+          expr: "0.5 * datum['month_\\'a\\''] + 0.5 * datum['month_\\'a\\'_end']",
+          as: `month_'a'_${OFFSETTED_RECT_END_SUFFIX}`
+        }
+      ]);
+    });
+
     it('should return a timeunit transform with step for bar with bandPosition=0', () => {
       const model = parseUnitModel({
         data: {values: []},
diff --git a/test/compositemark/boxplot.test.ts b/test/compositemark/boxplot.test.ts
index e4a1ecd39e..9cca7f6207 100644
--- a/test/compositemark/boxplot.test.ts
+++ b/test/compositemark/boxplot.test.ts
@@ -624,7 +624,7 @@ describe('normalizeBoxIQR', () => {
       transform: [
         {
           filter:
-            '(datum["people"] < datum["lower_box_people"] - 1.5 * (datum["upper_box_people"] - datum["lower_box_people"])) || (datum["people"] > datum["upper_box_people"] + 1.5 * (datum["upper_box_people"] - datum["lower_box_people"]))'
+            "(datum['people'] < datum['lower_box_people'] - 1.5 * (datum['upper_box_people'] - datum['lower_box_people'])) || (datum['people'] > datum['upper_box_people'] + 1.5 * (datum['upper_box_people'] - datum['lower_box_people']))"
         }
       ],
       mark: {
@@ -644,7 +644,7 @@ describe('normalizeBoxIQR', () => {
       transform: [
         {
           filter:
-            '(datum["lower_box_people"] - 1.5 * (datum["upper_box_people"] - datum["lower_box_people"]) <= datum["people"]) && (datum["people"] <= datum["upper_box_people"] + 1.5 * (datum["upper_box_people"] - datum["lower_box_people"]))'
+            "(datum['lower_box_people'] - 1.5 * (datum['upper_box_people'] - datum['lower_box_people']) <= datum['people']) && (datum['people'] <= datum['upper_box_people'] + 1.5 * (datum['upper_box_people'] - datum['lower_box_people']))"
         },
         {
           aggregate: [
diff --git a/test/compositemark/common.test.ts b/test/compositemark/common.test.ts
index 96fe81f64c..c52adfba21 100644
--- a/test/compositemark/common.test.ts
+++ b/test/compositemark/common.test.ts
@@ -98,12 +98,12 @@ describe('common', () => {
 
     const upperCalculate = transforms[1];
     expect(isCalculate(upperCalculate) && upperCalculate.calculate).toBe(
-      'datum["center_yield space,punctuation"] + datum["extent_yield space,punctuation"]'
+      "datum['center_yield space,punctuation'] + datum['extent_yield space,punctuation']"
     );
 
     const lowerCalculate = transforms[2];
     expect(isCalculate(lowerCalculate) && lowerCalculate.calculate).toBe(
-      'datum["center_yield space,punctuation"] - datum["extent_yield space,punctuation"]'
+      "datum['center_yield space,punctuation'] - datum['extent_yield space,punctuation']"
     );
   });
 
diff --git a/test/compositemark/errorband.test.ts b/test/compositemark/errorband.test.ts
index 4466d3a7fe..bed312e7c3 100644
--- a/test/compositemark/errorband.test.ts
+++ b/test/compositemark/errorband.test.ts
@@ -37,11 +37,11 @@ describe('normalizeErrorBand', () => {
           groupby: ['age']
         },
         {
-          calculate: 'datum["center_people"] + datum["extent_people"]',
+          calculate: "datum['center_people'] + datum['extent_people']",
           as: 'upper_people'
         },
         {
-          calculate: 'datum["center_people"] - datum["extent_people"]',
+          calculate: "datum['center_people'] - datum['extent_people']",
           as: 'lower_people'
         }
       ],
diff --git a/test/compositemark/errorbar.test.ts b/test/compositemark/errorbar.test.ts
index 866875aee8..0500cfed2a 100644
--- a/test/compositemark/errorbar.test.ts
+++ b/test/compositemark/errorbar.test.ts
@@ -44,11 +44,11 @@ describe('normalizeErrorBar with raw data input', () => {
           groupby: ['age']
         },
         {
-          calculate: 'datum["center_people"] + datum["extent_people"]',
+          calculate: "datum['center_people'] + datum['extent_people']",
           as: 'upper_people'
         },
         {
-          calculate: 'datum["center_people"] - datum["extent_people"]',
+          calculate: "datum['center_people'] - datum['extent_people']",
           as: 'lower_people'
         }
       ],
@@ -638,8 +638,8 @@ describe('normalizeErrorBar with aggregated upper and lower bound input', () =>
     ).toEqual({
       data,
       transform: [
-        {calculate: 'datum["people2"]', as: 'upper_people'},
-        {calculate: 'datum["people"]', as: 'lower_people'}
+        {calculate: "datum['people2']", as: 'upper_people'},
+        {calculate: "datum['people']", as: 'lower_people'}
       ],
       mark: {type: 'rule', ariaRoleDescription: 'errorbar', style: 'errorbar-rule'},
       encoding: {
@@ -678,8 +678,8 @@ describe('normalizeErrorBar with aggregated upper and lower bound input', () =>
 
       if (isCalculate(calculate)) {
         expect(
-          (calculate.calculate === 'datum["people"]' && calculate.as === 'lower_people') ||
-            (calculate.calculate === 'datum["people2"]' && calculate.as === 'upper_people')
+          (calculate.calculate === "datum['people']" && calculate.as === 'lower_people') ||
+            (calculate.calculate === "datum['people2']" && calculate.as === 'upper_people')
         ).toBe(true);
       } else {
         expect(false).toBe(true);
@@ -807,8 +807,8 @@ describe('normalizeErrorBar with aggregated error input', () => {
     ).toEqual({
       data,
       transform: [
-        {calculate: 'datum["people"] + datum["people_error"]', as: 'upper_people'},
-        {calculate: 'datum["people"] - datum["people_error"]', as: 'lower_people'}
+        {calculate: "datum['people'] + datum['people_error']", as: 'upper_people'},
+        {calculate: "datum['people'] - datum['people_error']", as: 'lower_people'}
       ],
       mark: {type: 'rule', ariaRoleDescription: 'errorbar', style: 'errorbar-rule'},
       encoding: {
@@ -848,8 +848,8 @@ describe('normalizeErrorBar with aggregated error input', () => {
 
       if (isCalculate(calculate)) {
         expect(
-          (calculate.calculate === 'datum["people"] - datum["people_error"]' && calculate.as === 'lower_people') ||
-            (calculate.calculate === 'datum["people"] + datum["people_error"]' && calculate.as === 'upper_people')
+          (calculate.calculate === "datum['people'] - datum['people_error']" && calculate.as === 'lower_people') ||
+            (calculate.calculate === "datum['people'] + datum['people_error']" && calculate.as === 'upper_people')
         ).toBe(true);
       } else {
         expect(false).toBe(true);
@@ -884,8 +884,8 @@ describe('normalizeErrorBar with aggregated error input', () => {
 
       if (isCalculate(calculate)) {
         expect(
-          (calculate.calculate === 'datum["people"] + datum["people_error"]' && calculate.as === 'upper_people') ||
-            (calculate.calculate === 'datum["people"] + datum["people_error2"]' && calculate.as === 'lower_people')
+          (calculate.calculate === "datum['people'] + datum['people_error']" && calculate.as === 'upper_people') ||
+            (calculate.calculate === "datum['people'] + datum['people_error2']" && calculate.as === 'lower_people')
         ).toBe(true);
       } else {
         expect(false).toBe(true);
diff --git a/test/normalize/core.test.ts b/test/normalize/core.test.ts
index 75318298b7..0a8ad693f7 100644
--- a/test/normalize/core.test.ts
+++ b/test/normalize/core.test.ts
@@ -232,11 +232,11 @@ describe('normalize()', () => {
                   groupby: ['age']
                 },
                 {
-                  calculate: 'datum["center_people"] + datum["extent_people"]',
+                  calculate: "datum['center_people'] + datum['extent_people']",
                   as: 'upper_people'
                 },
                 {
-                  calculate: 'datum["center_people"] - datum["extent_people"]',
+                  calculate: "datum['center_people'] - datum['extent_people']",
                   as: 'lower_people'
                 }
               ],