std::string avro2sql_create_table_statement(const std::string& tablename, const avro::ValidSchema& schema) { auto r = schema.root(); assert(r->type() == avro::AVRO_RECORD); std::string s = "CREATE TABLE " + tablename + " (\n"; size_t sz = r->names(); for (int i = 0; i != sz; ++i) { s += r->nameAt(i) + " " + to_string(avro_type_to_oid(r->leafAt(i)->type())); if (i != sz - 1) s += ","; } s += ")"; return s; }
std::string avro2sql_column_names(const avro::ValidSchema& schema, avro::GenericDatum& datum) { auto r = schema.root(); assert(r->type() == avro::AVRO_RECORD); std::string s = "("; size_t sz = r->names(); for (int i = 0; i != sz; ++i) { s += r->nameAt(i); if (i != sz - 1) s += ","; } s += ")"; /* schema->toJson(std::cerr); std::cerr << std::endl; return "unknown"; */ return s; }
bool QualifiedNameId::isEqualTo(const Name *other) const { const QualifiedNameId *q = other->asQualifiedNameId(); if (! q) return false; else if (isGlobal() != q->isGlobal()) return false; else { const unsigned count = nameCount(); if (count != q->nameCount()) return false; for (unsigned i = 0; i < count; ++i) { Name *l = nameAt(i); Name *r = q->nameAt(i); if (! l->isEqualTo(r)) return false; } } return true; }
QString ColorScheme::nameFromKey( const QString &key ) const { return nameAt( KeyName.indexOf( key ) ); }