public Task InsertRowsAsync(IEnumerable <GoogleBigQueryRow> rows, CancellationToken cancellationToken)
        {
            if (rows != null && rows.Count() > 0)
            {
                return(GetTableAsync(cancellationToken)
                       .ContinueWith((tableTask) =>
                {
                    BigQueryTable table = tableTask.Result;

                    var bigQueryRows = rows.Select(c => BigQueryInsertRowService.GetBigQueryInsertRow(c, dictionaryOfProperties)).ToArray();

                    return table.InsertRowsAsync(bigQueryRows, new InsertOptions()
                    {
                        AllowUnknownFields = false
                    }, cancellationToken)
                    .ContinueWith((insertRowsTask) =>
                    {
                        if (insertRowsTask.IsFaulted)
                        {
                            throw insertRowsTask.Exception.InnerExceptions.First();
                        }
                    });
                }, cancellationToken).Unwrap());
            }

            return(Task.CompletedTask);
        }
        public Task InsertRowsAsync(DateTime date, IEnumerable <GoogleBigQueryRow> rows, CancellationToken cancellationToken)
        {
            if (rows != null && rows.Count() > 0)
            {
                int dateDiff = (date - DateTime.UtcNow.Date).Days;

                if (dateDiff >= -31 && dateDiff <= 16)
                {
                    var bigQueryRows = rows.Select(c => BigQueryInsertRowService.GetBigQueryInsertRow(c, dictionaryOfProperties));

                    return(GetTableAsync(date, cancellationToken)
                           .ContinueWith((tableTask) =>
                    {
                        BigQueryTable table = tableTask.Result;

                        return table.InsertRowsAsync(bigQueryRows, new InsertOptions()
                        {
                            AllowUnknownFields = true
                        }, cancellationToken)
                        .ContinueWith((insertRowsTask) =>
                        {
                            if (insertRowsTask.IsFaulted)
                            {
                                throw insertRowsTask.Exception.InnerExceptions.First();
                            }
                        });
                    }, cancellationToken).Unwrap());
                }
                else
                {
                    throw new ArgumentOutOfRangeException("BigQuery streamming API don't allow to write data in DAY partioned tabled outside 31 days in the past and 16 days in the future.");
                }
            }

            return(Task.CompletedTask);
        }