1
votes

I am following the instructions in the following post to write to a date-partitioned table in BigQuery. I am using a serializable function to map the the window to a partition-location using the $ syntax and I get the following error:

Invalid table ID \"table$19700822\". Table IDs must be alphanumeric (plus underscores) and must be at most 1024 characters long.

Am I missing something here?

Edit adding code:

p.apply(Window.<TableRow>into(FixedWindows.of(Duration.standardDays(1))))
    .apply(BigQueryIO.Write
    .named("Write")
    .withSchema(schema)
    .withWriteDisposition(BigQueryIO.Write.WriteDisposition.WRITE_APPEND)
    .withCreateDisposition(BigQueryIO.Write.CreateDisposition.CREATE_IF_NEEDED)
    .to(new SerializableFunction<BoundedWindow, String>() {
      public String apply(BoundedWindow window) {
        String dayString = DateTimeFormat.forPattern("yyyyMMdd")
             .withZone(DateTimeZone.UTC)
             .print(((IntervalWindow) window).start());
        return "project_id:dataset.table$" + dayString;
      }
    }));
1
I don't think so because the output of the serializable function actually looks like: project-id:dataset.table$YYYYMMDDNarek
Could you provide the code that you're using?Sonya
@Sonya I added the code I am using.Narek

1 Answers

2
votes

Make sure that the table you're trying to access already exists. You can't create a table with "$" in it, and you're using "create if needed", so that your code might end up creating the table in addition to trying to write to it.