Skip to content

Commit

Permalink
Merge pull request #23130 from benesch/test-ruby
Browse files Browse the repository at this point in the history
test/lang: add ruby language tests
  • Loading branch information
benesch authored Nov 11, 2023
2 parents af2355d + 7a8aa17 commit 2fe05cf
Show file tree
Hide file tree
Showing 16 changed files with 646 additions and 112 deletions.
1 change: 1 addition & 0 deletions bin/lint
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ copyright_files=$(grep -vE \
-e '(^|/)Cargo\.lock$' \
-e '^about\.toml$' \
-e '^deny\.toml$' \
-e '(^|/)Gemfile\.lock$' \
-e '^netlify\.toml$' \
-e '^rustfmt\.toml$' \
-e '^clippy\.toml$' \
Expand Down
12 changes: 12 additions & 0 deletions ci/test/pipeline.template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,18 @@ steps:
agents:
queue: linux-x86_64

- id: lang-ruby
label: ":ruby: tests"
depends_on: build-x86_64
timeout_in_minutes: 10
inputs: [test/lang/ruby]
artifact_paths: junit_*.xml
plugins:
- ./ci/plugins/mzcompose:
composition: ruby
agents:
queue: linux-x86_64

- id: deploy-website
label: Deploy website
depends_on: lint-docs
Expand Down
32 changes: 25 additions & 7 deletions src/adapter/src/catalog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ impl Catalog {
details: CatalogTypeDetails {
array_id: builtin.details.array_id,
typ,
typreceive_oid: builtin.details.typreceive_oid,
pg_metadata: builtin.details.pg_metadata.clone(),
},
}
}
Expand Down Expand Up @@ -4865,7 +4865,8 @@ mod tests {
ty: String,
elem: u32,
array: u32,
receive: Option<u32>,
input: u32,
receive: u32,
}

struct PgOper {
Expand Down Expand Up @@ -4902,7 +4903,7 @@ mod tests {

let pg_type: BTreeMap<_, _> = client
.query(
"SELECT oid, typname, typtype::text, typelem, typarray, nullif(typreceive::oid, 0) as typreceive FROM pg_type",
"SELECT oid, typname, typtype::text, typelem, typarray, typinput::oid, typreceive::oid as typreceive FROM pg_type",
&[],
)
.await
Expand All @@ -4915,6 +4916,7 @@ mod tests {
ty: row.get("typtype"),
elem: row.get("typelem"),
array: row.get("typarray"),
input: row.get("typinput"),
receive: row.get("typreceive"),
};
(oid, pg_type)
Expand Down Expand Up @@ -5004,13 +5006,29 @@ mod tests {
ty.oid, pg_ty.name, ty.name,
);

let (typinput_oid, typreceive_oid) = match &ty.details.pg_metadata {
None => (0, 0),
Some(pgmeta) => (pgmeta.typinput_oid, pgmeta.typreceive_oid),
};
assert_eq!(
typinput_oid, pg_ty.input,
"type {} has typinput OID {:?} in mz but {:?} in pg",
ty.name, typinput_oid, pg_ty.input,
);
assert_eq!(
ty.details.typreceive_oid, pg_ty.receive,
typreceive_oid, pg_ty.receive,
"type {} has typreceive OID {:?} in mz but {:?} in pg",
ty.name, ty.details.typreceive_oid, pg_ty.receive,
ty.name, typreceive_oid, pg_ty.receive,
);

if let Some(typreceive_oid) = ty.details.typreceive_oid {
if typinput_oid != 0 {
assert!(
func_oids.contains(&typinput_oid),
"type {} has typinput OID {} that does not exist in pg_proc",
ty.name,
typinput_oid,
);
}
if typreceive_oid != 0 {
assert!(
func_oids.contains(&typreceive_oid),
"type {} has typreceive OID {} that does not exist in pg_proc",
Expand Down
5 changes: 3 additions & 2 deletions src/adapter/src/catalog/builtin_table_updates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -964,12 +964,13 @@ impl CatalogState {
diff,
});

if let Some(typreceive_oid) = typ.details.typreceive_oid {
if let Some(pg_metadata) = &typ.details.pg_metadata {
out.push(BuiltinTableUpdate {
id: self.resolve_builtin_table(&MZ_TYPE_PG_METADATA),
row: Row::pack_slice(&[
Datum::String(&id.to_string()),
Datum::UInt32(typreceive_oid),
Datum::UInt32(pg_metadata.typinput_oid),
Datum::UInt32(pg_metadata.typreceive_oid),
]),
diff,
});
Expand Down
2 changes: 1 addition & 1 deletion src/adapter/src/catalog/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,7 @@ impl CatalogState {
details: CatalogTypeDetails {
array_id: None,
typ: typ.inner,
typreceive_oid: None,
pg_metadata: None,
},
resolved_ids,
}),
Expand Down
2 changes: 1 addition & 1 deletion src/adapter/src/coord/sequencer/inner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1239,7 +1239,7 @@ impl Coordinator {
details: CatalogTypeDetails {
array_id: None,
typ: plan.typ.inner,
typreceive_oid: None,
pg_metadata: None,
},
resolved_ids,
};
Expand Down
Loading

0 comments on commit 2fe05cf

Please sign in to comment.