public void GeographyParameter()
        {
            var row = GetSingleRow("SELECT @p AS WKT",
                                   new BigQueryParameter("p", BigQueryDbType.Geography, BigQueryGeography.Parse("POINT(1 2)")));

            Assert.Equal(BigQueryGeography.Parse("POINT(1 2)"), (BigQueryGeography)row["WKT"]);
        }
Exemple #2
0
        private void ValidateRows(List <BigQueryRow> rows)
        {
            Assert.Equal(1, rows.Count);
            var row = rows[0];

            Assert.Equal("single string value", (string)row["single_string"]);
            Assert.Equal(true, (bool)row["single_bool"]);
            Assert.Equal(Encoding.UTF8.GetBytes("some bytes"), (byte[])row["single_bytes"]);
            AssertDateTimeEqual(new DateTime(2017, 2, 14, 0, 0, 0, DateTimeKind.Unspecified), (DateTime)row["single_date"]);
            AssertDateTimeEqual(new DateTime(2017, 2, 14, 10, 11, 12, DateTimeKind.Unspecified), (DateTime)row["single_datetime"]);
            Assert.Equal(new TimeSpan(12, 15, 22) + TimeSpan.FromTicks(1234560), (TimeSpan)row["single_time"]);
            AssertDateTimeEqual(new DateTime(2017, 1, 20, 5, 6, 37, DateTimeKind.Utc) + TimeSpan.FromTicks(6543210), (DateTime)row["single_timestamp"]);
            Assert.Equal(123456789012L, (long)row["single_int64"]);
            Assert.Equal(1.25, (double)row["single_float64"]);
            Assert.Equal(BigQueryNumeric.Parse("1234567890123456789012345678.123456789"), (BigQueryNumeric)row["single_numeric"]);
            Assert.Equal(BigQueryGeography.Parse("POINT(1 2)"), (BigQueryGeography)row["single_geography"]);

            var singleRecord = (Dictionary <string, object>)row["single_record"];

            Assert.Equal("nested string", (string)singleRecord["single_string"]);
            Assert.Equal(new[] { "nested string 1", "nested string 2" }, (string[])singleRecord["repeated_string"]);
            var nestedRecord = (Dictionary <string, object>)singleRecord["nested_record"];

            Assert.Equal(-10L, (long)nestedRecord["a"]);
            Assert.Equal(20L, (long)nestedRecord["b"]);

            Assert.Equal(new[] { "array string value 1", "array string value 2" }, (string[])row["array_string"]);
            Assert.Equal(new[] { true, false }, (bool[])row["array_bool"]);
            Assert.Equal(new[] { Encoding.UTF8.GetBytes("bytes1"), Encoding.UTF8.GetBytes("bytes2") }, (byte[][])row["array_bytes"]);
            AssertDateTimesEqual(
                new[] { new DateTime(2017, 2, 15), new DateTime(2017, 2, 16) },
                (DateTime[])row["array_date"]);
            AssertDateTimesEqual(
                new[] { new DateTime(2017, 2, 15, 10, 11, 12, DateTimeKind.Unspecified), new DateTime(2017, 2, 16, 10, 11, 12, DateTimeKind.Unspecified) },
                (DateTime[])row["array_datetime"]);
            Assert.Equal(new[] { new TimeSpan(12, 15, 22), new TimeSpan(10, 53, 10) }, (TimeSpan[])row["array_time"]);
            AssertDateTimesEqual(
                new[] { new DateTime(2017, 3, 20, 5, 6, 37, DateTimeKind.Utc), new DateTime(2017, 4, 20, 5, 6, 37, DateTimeKind.Utc) },
                (DateTime[])row["array_timestamp"]);
            Assert.Equal(new [] { 1234567890123L, 12345678901234L }, (long[])row["array_int64"]);
            Assert.Equal(new[] { -1.25, 2.5 }, (double[])row["array_float64"]);
            Assert.Equal(new[] { BigQueryNumeric.Parse("1234567890123456789012345678.123456789"), BigQueryNumeric.Parse("123.456") },
                         (BigQueryNumeric[])row["array_numeric"]);
            Assert.Equal(new[] { BigQueryGeography.Parse("POINT(1 2)"), BigQueryGeography.Parse("POINT(1 3)") },
                         (BigQueryGeography[])row["array_geography"]);

            var arrayRecords = (Dictionary <string, object>[])row["array_record"];

            Assert.Equal("array record string 1", (string)arrayRecords[0]["single_string"]);
            Assert.Equal(new[] { "array record string 1.1", "array record string 1.2" }, (string[])arrayRecords[0]["repeated_string"]);
            nestedRecord = (Dictionary <string, object>)arrayRecords[0]["nested_record"];
            Assert.Equal(-100L, (long)nestedRecord["a"]);
            Assert.Equal(200L, (long)nestedRecord["b"]);

            Assert.Equal("array record string 2", (string)arrayRecords[1]["single_string"]);
            Assert.Equal(new[] { "array record string 2.1", "array record string 2.2" }, (string[])arrayRecords[1]["repeated_string"]);
            nestedRecord = (Dictionary <string, object>)arrayRecords[1]["nested_record"];
            Assert.Equal(-1000L, (long)nestedRecord["a"]);
            Assert.Equal(2000L, (long)nestedRecord["b"]);
        }
Exemple #3
0
        public void Parse()
        {
            var text      = "POINT(30 10)";
            var geography = BigQueryGeography.Parse(text);

            Assert.Equal(text, geography.Text);
            Assert.Equal(text, geography.ToString());
        }
Exemple #4
0
 public void Equality()
 {
     EqualityTester.AssertEqual(BigQueryGeography.Parse("POINT(30 10)"),
                                new[] { BigQueryGeography.Parse("POINT(30 10)") },
                                new[]
     {
         BigQueryGeography.Parse("POINT (30 10)"),     // Whitespace is relevant
         BigQueryGeography.Parse("POINT"),
         BigQueryGeography.Parse("LINESTRING (30 10, 10 30, 40 40)")
     });
 }
Exemple #5
0
        // Here rather than in the fixture (where it's used) for ease of writing/checking the tests above.
        internal static BigQueryInsertRow GetSampleRow() => new BigQueryInsertRow
        {
            ["single_string"]    = "single string value",
            ["single_bool"]      = true,
            ["single_bytes"]     = Encoding.UTF8.GetBytes("some bytes"),
            ["single_date"]      = new DateTime(2017, 2, 14).AsBigQueryDate(),
            ["single_datetime"]  = new DateTime(2017, 2, 14, 10, 11, 12, DateTimeKind.Unspecified),
            ["single_time"]      = new TimeSpan(12, 15, 22) + TimeSpan.FromTicks(1234560), // 10 ticks per microsecond
            ["single_timestamp"] = new DateTime(2017, 1, 20, 5, 6, 37, DateTimeKind.Utc) + TimeSpan.FromTicks(6543210),
            ["single_int64"]     = 123456789012L,                                          // Larger than an int32
            ["single_float64"]   = 1.25,
            ["single_numeric"]   = BigQueryNumeric.Parse("1234567890123456789012345678.123456789"),
            ["single_geography"] = BigQueryGeography.Parse("POINT(1 2)"),
            ["single_record"]    = new BigQueryInsertRow
            {
                ["single_string"]   = "nested string",
                ["repeated_string"] = new[] { "nested string 1", "nested string 2" },
                ["nested_record"]   = new BigQueryInsertRow {
                    ["a"] = -10, ["b"] = 20
                }
            },

            ["array_string"]    = new[] { "array string value 1", "array string value 2" },
            ["array_bool"]      = new[] { true, false },
            ["array_bytes"]     = new[] { Encoding.UTF8.GetBytes("bytes1"), Encoding.UTF8.GetBytes("bytes2") },
            ["array_date"]      = new[] { new DateTime(2017, 2, 15).AsBigQueryDate(), new DateTime(2017, 2, 16).AsBigQueryDate() },
            ["array_datetime"]  = new[] { new DateTime(2017, 2, 15, 10, 11, 12, DateTimeKind.Unspecified), new DateTime(2017, 2, 16, 10, 11, 12, DateTimeKind.Unspecified) },
            ["array_time"]      = new[] { new TimeSpan(12, 15, 22), new TimeSpan(10, 53, 10) },
            ["array_timestamp"] = new[] { new DateTime(2017, 3, 20, 5, 6, 37, DateTimeKind.Utc), new DateTime(2017, 4, 20, 5, 6, 37, DateTimeKind.Utc) },
            ["array_int64"]     = new[] { 1234567890123L, 12345678901234L },
            ["array_float64"]   = new[] { -1.25, 2.5 },
            ["array_numeric"]   = new[] { BigQueryNumeric.Parse("1234567890123456789012345678.123456789"), BigQueryNumeric.Parse("123.456") },
            ["array_geography"] = new[] { BigQueryGeography.Parse("POINT(1 2)"), BigQueryGeography.Parse("POINT(1 3)") },
            ["array_record"]    = new[] {
                new BigQueryInsertRow
                {
                    ["single_string"]   = "array record string 1",
                    ["repeated_string"] = new[] { "array record string 1.1", "array record string 1.2" },
                    ["nested_record"]   = new BigQueryInsertRow {
                        ["a"] = -100, ["b"] = 200
                    }
                },
                new BigQueryInsertRow
                {
                    ["single_string"]   = "array record string 2",
                    ["repeated_string"] = new[] { "array record string 2.1", "array record string 2.2" },
                    ["nested_record"]   = new BigQueryInsertRow {
                        ["a"] = -1000, ["b"] = 2000
                    }
                },
            }
        };
Exemple #6
0
        public void QueryParameters()
        {
            var client = BigQueryClient.Create(_fixture.ProjectId);

            AssertParameterRoundTrip(client, new BigQueryParameter(BigQueryDbType.String, "foo"));
            AssertParameterRoundTrip(client, new BigQueryParameter(BigQueryDbType.Bool, true));
            AssertParameterRoundTrip(client, new BigQueryParameter(BigQueryDbType.Int64, 123456L));
            AssertParameterRoundTrip(client, new BigQueryParameter(BigQueryDbType.Float64, 123.75));
            AssertParameterRoundTrip(client, new BigQueryParameter(BigQueryDbType.Bytes, new byte[] { 1, 2, 3, 4 }));
            AssertParameterRoundTrip(client, new BigQueryParameter(BigQueryDbType.Date, new DateTime(2017, 2, 14)));
            AssertParameterRoundTrip(client, new BigQueryParameter(BigQueryDbType.DateTime, new DateTime(2017, 2, 14, 17, 25, 30, DateTimeKind.Unspecified)));
            AssertParameterRoundTrip(client, new BigQueryParameter(BigQueryDbType.Timestamp, new DateTime(2017, 2, 14, 17, 25, 30, DateTimeKind.Utc)));
            AssertParameterRoundTrip(client, new BigQueryParameter(BigQueryDbType.Time, new TimeSpan(0, 1, 2, 3, 456)));
            AssertParameterRoundTrip(client, new BigQueryParameter(BigQueryDbType.Numeric, BigQueryNumeric.Parse("1234567890123456789012345678.123456789")));
            AssertParameterRoundTrip(client, new BigQueryParameter(BigQueryDbType.Geography, BigQueryGeography.Parse("POINT(1 2)")));

            AssertParameterRoundTrip(client, new BigQueryParameter(BigQueryDbType.Array, new[] { "foo", "bar" }));
            AssertParameterRoundTrip(client, new BigQueryParameter(BigQueryDbType.Array, new[] { true, false }));
            AssertParameterRoundTrip(client, new BigQueryParameter(BigQueryDbType.Array, new[] { 123456L, -1234L }));
            AssertParameterRoundTrip(client, new BigQueryParameter(BigQueryDbType.Array, new[] { 123.75, 10.5 }));
            AssertParameterRoundTrip(client, new BigQueryParameter(BigQueryDbType.Array, new[] { new byte[] { 1, 2, 3, 4 }, new byte[] { 255, 254, 253, 252 } }));
            // Date/DateTime/Timestamp arrays need to be given the types explicitly.
            AssertParameterRoundTrip(client, new BigQueryParameter(BigQueryDbType.Array,
                                                                   new[] { new DateTime(2017, 2, 14), new DateTime(2017, 2, 15) })
            {
                ArrayElementType = BigQueryDbType.Date
            });
            AssertParameterRoundTrip(client, new BigQueryParameter(BigQueryDbType.Array,
                                                                   new[] { new DateTime(2017, 2, 14, 17, 25, 30, DateTimeKind.Unspecified), new DateTime(2017, 2, 15, 17, 25, 30, DateTimeKind.Unspecified) })
            {
                ArrayElementType = BigQueryDbType.DateTime
            });
            AssertParameterRoundTrip(client, new BigQueryParameter(BigQueryDbType.Array,
                                                                   new[] { new DateTime(2017, 2, 14, 17, 25, 30, DateTimeKind.Utc), new DateTime(2017, 2, 15, 17, 25, 30, DateTimeKind.Utc) })
            {
                ArrayElementType = BigQueryDbType.Timestamp
            });
            AssertParameterRoundTrip(client, new BigQueryParameter(BigQueryDbType.Array,
                                                                   new[] { new TimeSpan(0, 1, 2, 3, 456), new TimeSpan(0, 23, 59, 59, 987) }));
            AssertParameterRoundTrip(client, new BigQueryParameter(BigQueryDbType.Array,
                                                                   new[] { BigQueryNumeric.Parse("1234567890123456789012345678.123456789"), BigQueryNumeric.Parse("123.456") }));
            AssertParameterRoundTrip(client, new BigQueryParameter(BigQueryDbType.Array,
                                                                   new[] { BigQueryGeography.Parse("POINT(1 2)"), BigQueryGeography.Parse("POINT(1 3)") }));
        }
Exemple #7
0
        public void Scalars()
        {
            var schema = new TableSchemaBuilder
            {
                { "integer", BigQueryDbType.Int64 },
                { "bool", BigQueryDbType.Bool },
                { "bytes", BigQueryDbType.Bytes },
                { "float", BigQueryDbType.Float64 },
                { "string", BigQueryDbType.String },
                { "timestamp", BigQueryDbType.Timestamp },
                { "date", BigQueryDbType.Date },
                { "dateTime", BigQueryDbType.DateTime },
                { "time", BigQueryDbType.Time },
                { "numeric", BigQueryDbType.Numeric },
                { "geography", BigQueryDbType.Geography },
                { "struct", new TableSchemaBuilder {
                      { "x", BigQueryDbType.Int64 }, { "y", BigQueryDbType.String }
                  } }
            }.Build();
            var rawRow = new TableRow
            {
                F = new[]
                {
                    new TableCell {
                        V = "10"
                    },
                    new TableCell {
                        V = "true"
                    },
                    new TableCell {
                        V = "AQI="
                    },                            // 1, 2
                    new TableCell {
                        V = "2.5"
                    },
                    new TableCell {
                        V = "text"
                    },
                    new TableCell {
                        V = "1477566580.5"
                    },                                    // 2016-10-27T11:09:40.500Z
                    new TableCell {
                        V = "2017-08-09"
                    },
                    new TableCell {
                        V = "2017-08-09T12:34:56.123"
                    },
                    new TableCell {
                        V = "12:34:56.123"
                    },
                    new TableCell {
                        V = "1234567890123456789012345678.123456789"
                    },
                    new TableCell {
                        V = "POINT(1 2)"
                    },
                    new TableCell {
                        V = new JObject {
                            ["f"] = new JArray {
                                new JObject {
                                    ["v"] = "100"
                                }, new JObject {
                                    ["v"] = "xyz"
                                }
                            }
                        }
                    }
                }
            };
            var row = new BigQueryRow(rawRow, schema);

            Assert.Equal(10, (long)row["integer"]);
            Assert.Equal(true, (bool)row["bool"]);
            Assert.Equal(new byte[] { 1, 2 }, (byte[])row["bytes"]);
            Assert.Equal(2.5d, (double)row["float"]);
            Assert.Equal("text", (string)row["string"]);
            Assert.Equal(new DateTime(2016, 10, 27, 11, 9, 40, 500, DateTimeKind.Utc), (DateTime)row["timestamp"]);
            Assert.Equal(new DateTime(2017, 8, 9, 0, 0, 0, DateTimeKind.Utc), (DateTime)row["date"]);
            Assert.Equal(new DateTime(2017, 8, 9, 12, 34, 56, 123, DateTimeKind.Utc), (DateTime)row["dateTime"]);
            Assert.Equal(new TimeSpan(0, 12, 34, 56, 123), (TimeSpan)row["time"]);
            Assert.Equal(BigQueryNumeric.Parse("1234567890123456789012345678.123456789"), (BigQueryNumeric)row["numeric"]);
            Assert.Equal(BigQueryGeography.Parse("POINT(1 2)"), (BigQueryGeography)row["geography"]);
            Assert.Equal(new Dictionary <string, object> {
                { "x", 100L }, { "y", "xyz" }
            }, (Dictionary <string, object>)row["struct"]);
        }
Exemple #8
0
        public void Arrays()
        {
            var schema = new TableSchemaBuilder
            {
                { "integer", BigQueryDbType.Int64, BigQueryFieldMode.Repeated },
                { "bool", BigQueryDbType.Bool, BigQueryFieldMode.Repeated },
                { "bytes", BigQueryDbType.Bytes, BigQueryFieldMode.Repeated },
                { "float", BigQueryDbType.Float64, BigQueryFieldMode.Repeated },
                { "string", BigQueryDbType.String, BigQueryFieldMode.Repeated },
                { "timestamp", BigQueryDbType.Timestamp, BigQueryFieldMode.Repeated },
                { "date", BigQueryDbType.Date, BigQueryFieldMode.Repeated },
                { "dateTime", BigQueryDbType.DateTime, BigQueryFieldMode.Repeated },
                { "time", BigQueryDbType.Time, BigQueryFieldMode.Repeated },
                { "numeric", BigQueryDbType.Numeric, BigQueryFieldMode.Repeated },
                { "geography", BigQueryDbType.Geography, BigQueryFieldMode.Repeated },
                { "struct", new TableSchemaBuilder {
                      { "x", BigQueryDbType.Int64 }, { "y", BigQueryDbType.String }
                  }, BigQueryFieldMode.Repeated }
            }.Build();
            var rawRow = new TableRow
            {
                F = new[]
                {
                    new TableCell {
                        V = CreateArray("10", "20")
                    },
                    new TableCell {
                        V = CreateArray("true", "false")
                    },
                    new TableCell {
                        V = CreateArray("AQI=", "AQM=")
                    },                                                 // [1, 2], [1, 3]
                    new TableCell {
                        V = CreateArray("2.5", "3.5")
                    },
                    new TableCell {
                        V = CreateArray("text", "more text")
                    },
                    new TableCell {
                        V = CreateArray("1477566580.5", "1477566581.5")
                    },                                                                 // 2016-10-27T11:09:40.500Z, 2016-10-27T11:09:41.500Z
                    new TableCell {
                        V = CreateArray("2017-08-09", "2017-08-10")
                    },
                    new TableCell {
                        V = CreateArray("2017-08-09T12:34:56.123", "2017-08-09T12:34:57.123")
                    },
                    new TableCell {
                        V = CreateArray("12:34:56.123", "12:34:57.123")
                    },
                    new TableCell {
                        V = CreateArray("1234567890123456789012345678.123456789", "0.000000001")
                    },
                    new TableCell {
                        V = CreateArray("POINT(1 3)", "POINT(2 4)")
                    },
                    new TableCell {
                        V = new JArray {
                            new JObject {
                                ["v"] = new JObject {
                                    ["f"] = new JArray {
                                        new JObject {
                                            ["v"] = "100"
                                        }, new JObject {
                                            ["v"] = "xyz"
                                        }
                                    }
                                }
                            },
                            new JObject {
                                ["v"] = new JObject {
                                    ["f"] = new JArray {
                                        new JObject {
                                            ["v"] = "200"
                                        }, new JObject {
                                            ["v"] = "abc"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            };
            var row = new BigQueryRow(rawRow, schema);

            Assert.Equal(new[] { 10L, 20L }, (long[])row["integer"]);
            Assert.Equal(new[] { true, false }, (bool[])row["bool"]);
            Assert.Equal(new[] { new byte[] { 1, 2 }, new byte[] { 1, 3 } }, (byte[][])row["bytes"]);
            Assert.Equal(new[] { 2.5d, 3.5d }, (double[])row["float"]);
            Assert.Equal(new[] { "text", "more text" }, (string[])row["string"]);
            Assert.Equal(new[] { new DateTime(2016, 10, 27, 11, 9, 40, 500, DateTimeKind.Utc), new DateTime(2016, 10, 27, 11, 9, 41, 500, DateTimeKind.Utc) },
                         (DateTime[])row["timestamp"]);
            Assert.Equal(new[] { new DateTime(2017, 8, 9, 0, 0, 0, DateTimeKind.Utc), new DateTime(2017, 8, 10, 0, 0, 0, DateTimeKind.Utc) },
                         (DateTime[])row["date"]);
            Assert.Equal(new[] { new DateTime(2017, 8, 9, 12, 34, 56, 123, DateTimeKind.Utc), new DateTime(2017, 8, 9, 12, 34, 57, 123, DateTimeKind.Utc) },
                         (DateTime[])row["dateTime"]);
            Assert.Equal(new[] { new TimeSpan(0, 12, 34, 56, 123), new TimeSpan(0, 12, 34, 57, 123) }, (TimeSpan[])row["time"]);
            Assert.Equal(new[] { BigQueryNumeric.Parse("1234567890123456789012345678.123456789"), BigQueryNumeric.Parse("0.000000001") }, (BigQueryNumeric[])row["numeric"]);
            Assert.Equal(new[] { BigQueryGeography.Parse("POINT(1 3)"), BigQueryGeography.Parse("POINT(2 4)") }, (BigQueryGeography[])row["geography"]);
            Assert.Equal(new[]
            {
                new Dictionary <string, object> {
                    { "x", 100L }, { "y", "xyz" }
                },
                new Dictionary <string, object> {
                    { "x", 200L }, { "y", "abc" }
                }
            },
                         (Dictionary <string, object>[])row["struct"]);
        }
        // Please excuse the very long lines... it's more readable than
        public static IEnumerable <object[]> ToQueryParameterData() => new[]
        {
            // Bool
            ScalarTest("Bool parameter, true", BigQueryDbType.Bool, true, "TRUE"),
            ScalarTest("Bool parameter, false", BigQueryDbType.Bool, false, "FALSE"),
            ScalarTest("Bool parameter, string value", BigQueryDbType.Bool, "maybe", "maybe"),
            ScalarTest("Bool parameter, null value", BigQueryDbType.Bool, null, null),

            // Float64
            ScalarTest("Float64 parameter, Int16 value", BigQueryDbType.Float64, (short)10, "10"),
            ScalarTest("Float64 parameter, Int32 value", BigQueryDbType.Float64, (int)10, "10"),
            ScalarTest("Float64 parameter, Int64 value", BigQueryDbType.Float64, (long)10, "10"),
            ScalarTest("Float64 parameter, UInt16 value", BigQueryDbType.Float64, (ushort)10, "10"),
            ScalarTest("Float64 parameter, UInt32 value", BigQueryDbType.Float64, (uint)10, "10"),
            ScalarTest("Float64 parameter, UInt64 value", BigQueryDbType.Float64, (ulong)10, "10"),
            ScalarTest("Float64 parameter, Single value", BigQueryDbType.Float64, 10.5f, "10.5"),
            ScalarTest("Float64 parameter, Double value", BigQueryDbType.Float64, 10.5, "10.5"),
            ScalarTest("Float64 parameter, Single value (+inf)", BigQueryDbType.Float64, float.PositiveInfinity, "+inf"),
            ScalarTest("Float64 parameter, Double value (+inf)", BigQueryDbType.Float64, double.PositiveInfinity, "+inf"),
            ScalarTest("Float64 parameter, Single value (-inf)", BigQueryDbType.Float64, float.NegativeInfinity, "-inf"),
            ScalarTest("Float64 parameter, Double value (-inf)", BigQueryDbType.Float64, double.NegativeInfinity, "-inf"),
            ScalarTest("Float64 parameter, Single value (NaN)", BigQueryDbType.Float64, float.NaN, "NaN"),
            ScalarTest("Float64 parameter, Double value (NaN)", BigQueryDbType.Float64, double.NaN, "NaN"),
            ScalarTest("Float64 parameter, string value", BigQueryDbType.Float64, "string value", "string value"),
            ScalarTest("Float64 parameter, null value", BigQueryDbType.Float64, null, null),

            // Int64...
            ScalarTest("Int64 parameter, Int16 value", BigQueryDbType.Int64, (short)10, "10"),
            ScalarTest("Int64 parameter, Int32 value", BigQueryDbType.Int64, (int)10, "10"),
            ScalarTest("Int64 parameter, Int64 value", BigQueryDbType.Int64, (long)10, "10"),
            ScalarTest("Int64 parameter, UInt16 value", BigQueryDbType.Int64, (ushort)10, "10"),
            ScalarTest("Int64 parameter, UInt32 value", BigQueryDbType.Int64, (uint)10, "10"),
            ScalarTest("Int64 parameter, UInt64 value", BigQueryDbType.Int64, (ulong)10, "10"),
            ScalarTest("Int64 parameter, string value", BigQueryDbType.Int64, "string value", "string value"),
            ScalarTest("Int64 parameter, null value", BigQueryDbType.Int64, null, null),

            // String...
            ScalarTest("String parameter, string value", BigQueryDbType.String, "some value", "some value"),
            ScalarTest("String parameter, null value", BigQueryDbType.String, null, null),

            // Bytes...
            ScalarTest("Bytes parameter, byte[] value", BigQueryDbType.Bytes, new byte[] { 1, 2 }, "AQI="),
            ScalarTest("Bytes parameter, string value", BigQueryDbType.Bytes, "some value", "some value"),
            ScalarTest("Bytes parameter, null value", BigQueryDbType.Bytes, null, null),

            // Date
            ScalarTest("Date parameter, DateTime value", BigQueryDbType.Date, new DateTime(2016, 10, 31), "2016-10-31"),
            // This is midnight local time on the 31st, which means its UTC value is actually 2016-10-30T22:00:00
            // - but we only care about the local value for Date parameters
            ScalarTest("Date parameter, DateTimeOffset value", BigQueryDbType.Date, new DateTimeOffset(2016, 10, 31, 0, 0, 0, TimeSpan.FromHours(2)), "2016-10-31"),
            ScalarTest("Date parameter, string value", BigQueryDbType.Date, "some value", "some value"),
            ScalarTest("Date parameter, null value", BigQueryDbType.Date, null, null),

            // DateTime
            // Value with ticks is truncated (not rounded). The Kind is irrelevant
            ScalarTest("DateTime parameter, DateTime value (local)", BigQueryDbType.DateTime,
                       new DateTime(2016, 10, 31, 1, 2, 3, 123, DateTimeKind.Local).AddTicks(4567),
                       "2016-10-31 01:02:03.123456"),
            ScalarTest("DateTime parameter, DateTime value (unspecified)", BigQueryDbType.DateTime,
                       new DateTime(2016, 10, 31, 1, 2, 3, 123, DateTimeKind.Unspecified).AddTicks(4567),
                       "2016-10-31 01:02:03.123456"),
            ScalarTest("DateTime parameter, DateTime value (UTC)", BigQueryDbType.DateTime,
                       new DateTime(2016, 10, 31, 1, 2, 3, 123, DateTimeKind.Utc).AddTicks(4567),
                       "2016-10-31 01:02:03.123456"),
            // This is midnight local time on the 31st, which means its UTC value is actually 2016-10-30T22:00:00
            // - but we only care about the local value for DateTime parameters
            ScalarTest("DateTime parameter, DateTimeOffset value", BigQueryDbType.DateTime,
                       new DateTimeOffset(2016, 10, 31, 0, 0, 0, TimeSpan.FromHours(2)), "2016-10-31 00:00:00"),
            ScalarTest("DateTime parameter, string value", BigQueryDbType.Date, "some value", "some value"),
            ScalarTest("DateTime parameter, null value", BigQueryDbType.Date, null, null),

            // Time
            // Truncated to microseconds
            ScalarTest("Time parameter, TimeSpan value", BigQueryDbType.Time,
                       TimeSpan.ParseExact("01:23:45.1234567", "hh':'mm':'ss'.'FFFFFFF", CultureInfo.InvariantCulture),
                       "01:23:45.123456"),
            // Truncated to a single day
            ScalarTest("Time parameter, TimeSpan value bigger than 24h", BigQueryDbType.Time,
                       TimeSpan.FromHours(25), "01:00:00.000000"),
            ScalarTest("Time parameter, TimeSpan value negative", BigQueryDbType.Time,
                       TimeSpan.FromHours(-1), "23:00:00.000000"),
            ScalarTest("Time parameter, TimeSpan value large negative", BigQueryDbType.Time,
                       TimeSpan.FromHours(-25), "23:00:00.000000"),
            ScalarTest("Time parameter, DateTime value", BigQueryDbType.Time,
                       new DateTime(2016, 10, 31, 1, 2, 3, 123).AddTicks(4567),
                       "01:02:03.123456"),
            ScalarTest("Time parameter, DateTimeOffset value", BigQueryDbType.Time,
                       new DateTimeOffset(2016, 10, 31, 1, 2, 3, 123, TimeSpan.FromHours(2)).AddTicks(4567),
                       "01:02:03.123456"),
            ScalarTest("Time parameter, string value", BigQueryDbType.Time, "some value", "some value"),
            ScalarTest("Time parameter, null value", BigQueryDbType.Time, null, null),

            // Timestamp
            ScalarTest("Timestamp parameter, DateTime value (UTC)", BigQueryDbType.Timestamp,
                       new DateTime(2016, 10, 31, 1, 2, 3, 123, DateTimeKind.Utc).AddTicks(4567),
                       "2016-10-31 01:02:03.123456+00"),
            ScalarTest("Timestamp parameter, DateTimeOffset value positive offset", BigQueryDbType.Timestamp,
                       new DateTimeOffset(2016, 10, 31, 0, 0, 0, TimeSpan.FromHours(2)), "2016-10-31 00:00:00+02:00"),
            ScalarTest("Timestamp parameter, DateTimeOffset value negative offset", BigQueryDbType.Timestamp,
                       new DateTimeOffset(2016, 10, 31, 0, 0, 0, TimeSpan.FromHours(-2)), "2016-10-31 00:00:00-02:00"),
            ScalarTest("Timestamp parameter, string value", BigQueryDbType.Timestamp, "some value", "some value"),
            ScalarTest("Timestamp parameter, null value", BigQueryDbType.Timestamp, null, null),

            // Numeric
            ScalarTest("Numeric parameter", BigQueryDbType.Numeric, BigQueryNumeric.Parse("123.45"), "123.45"),
            ScalarTest("Numeric parameter, string value", BigQueryDbType.Numeric, "string value", "string value"),
            ScalarTest("Numeric parameter, null value", BigQueryDbType.Numeric, null, null),

            // Geography (where the underlying value is just the string)
            ScalarTest("Geography parameter, BigQueryGeography value", BigQueryDbType.Geography, BigQueryGeography.Parse("POINT"), "POINT"),
            ScalarTest("Geogprahy parameter, string value", BigQueryDbType.Numeric, "POINT", "POINT"),
            ScalarTest("Geography parameter, null value", BigQueryDbType.Geography, null, null),
        };