Skip to content

Commit

Permalink
Merge branch 'main' into ci-throttler-grpc
Browse files Browse the repository at this point in the history
Signed-off-by: Shlomi Noach <[email protected]>
  • Loading branch information
shlomi-noach committed Feb 10, 2025
2 parents b0197ff + 4c9de0b commit 18bab44
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 42 deletions.
13 changes: 11 additions & 2 deletions go/vt/schemadiff/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -389,11 +389,20 @@ func (e *IndexNeededByForeignKeyError) Error() string {
}

type ViewDependencyUnresolvedError struct {
View string
View string
MissingReferencedEntities []string
}

func (e *ViewDependencyUnresolvedError) Error() string {
return fmt.Sprintf("view %s has unresolved/loop dependencies", sqlescape.EscapeID(e.View))
var b strings.Builder
fmt.Fprintf(&b, "view %s has unresolved/loop dependencies: ", sqlescape.EscapeID(e.View))
for i, entity := range e.MissingReferencedEntities {
if i > 0 {
b.WriteString(", ")
}
sqlescape.WriteEscapeID(&b, entity)
}
return b.String()
}

type InvalidColumnReferencedInViewError struct {
Expand Down
9 changes: 8 additions & 1 deletion go/vt/schemadiff/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,14 @@ func (s *Schema) normalize(hints *DiffHints) error {
if _, ok := dependencyLevels[v.Name()]; !ok {
// We _know_ that in this iteration, at least one view is found unassigned a dependency level.
// We gather all the errors.
errs = errors.Join(errs, &ViewDependencyUnresolvedError{View: v.ViewName.Name.String()})
dependentNames := getViewDependentTableNames(v.CreateView)
missingReferencedEntities := []string{}
for _, name := range dependentNames {
if _, ok := dependencyLevels[name]; !ok {
missingReferencedEntities = append(missingReferencedEntities, name)
}
}
errs = errors.Join(errs, &ViewDependencyUnresolvedError{View: v.ViewName.Name.String(), MissingReferencedEntities: missingReferencedEntities})
// We still add it so it shows up in the output if that is used for anything.
s.sorted = append(s.sorted, v)
}
Expand Down
22 changes: 18 additions & 4 deletions go/vt/schemadiff/schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,26 @@ func TestNewSchemaFromQueriesUnresolved(t *testing.T) {
)
schema, err := NewSchemaFromQueries(NewTestEnv(), queries)
assert.Error(t, err)
assert.EqualError(t, err, (&ViewDependencyUnresolvedError{View: "v7"}).Error())
assert.EqualError(t, err, (&ViewDependencyUnresolvedError{View: "v7", MissingReferencedEntities: []string{"v8"}}).Error())
v := schema.sorted[len(schema.sorted)-1]
assert.IsType(t, &CreateViewEntity{}, v)
assert.Equal(t, "CREATE VIEW `v7` AS SELECT * FROM `v8`, `t2`", v.Create().CanonicalStatementString())
}

func TestNewSchemaFromQueriesUnresolvedMulti(t *testing.T) {
// v8 does not exist
queries := append(schemaTestCreateQueries,
"create view v7 as select * from v8, t2, t20, v21",
)
schema, err := NewSchemaFromQueries(NewTestEnv(), queries)
assert.Error(t, err)
assert.EqualError(t, err, (&ViewDependencyUnresolvedError{View: "v7", MissingReferencedEntities: []string{"v8", "t20", "v21"}}).Error())
assert.Equal(t, "view `v7` has unresolved/loop dependencies: `v8`, `t20`, `v21`", err.Error())
v := schema.sorted[len(schema.sorted)-1]
assert.IsType(t, &CreateViewEntity{}, v)
assert.Equal(t, "CREATE VIEW `v7` AS SELECT * FROM `v8`, `t2`, `t20`, `v21`", v.Create().CanonicalStatementString())
}

func TestNewSchemaFromQueriesWithSQLKeyword(t *testing.T) {
queries := []string{
"create table `order` (id int primary key, info int not null)",
Expand All @@ -141,7 +155,7 @@ func TestNewSchemaFromQueriesUnresolvedAlias(t *testing.T) {
)
_, err := NewSchemaFromQueries(NewTestEnv(), queries)
assert.Error(t, err)
assert.EqualError(t, err, (&ViewDependencyUnresolvedError{View: "v7"}).Error())
assert.EqualError(t, err, (&ViewDependencyUnresolvedError{View: "v7", MissingReferencedEntities: []string{"something_else"}}).Error())
}

func TestNewSchemaFromQueriesViewFromDual(t *testing.T) {
Expand Down Expand Up @@ -171,7 +185,7 @@ func TestNewSchemaFromQueriesLoop(t *testing.T) {
_, err := NewSchemaFromQueries(NewTestEnv(), queries)
require.Error(t, err)
err = vterrors.UnwrapFirst(err)
assert.EqualError(t, err, (&ViewDependencyUnresolvedError{View: "v7"}).Error())
assert.EqualError(t, err, (&ViewDependencyUnresolvedError{View: "v7", MissingReferencedEntities: []string{"v8"}}).Error())
}

func TestToSQL(t *testing.T) {
Expand Down Expand Up @@ -582,7 +596,7 @@ SELECT
) AS ranking
FROM users AS u JOIN earnings AS e ON e.user_id = u.id;
`,
expectErr: &ViewDependencyUnresolvedError{View: "user_earnings_ranking"},
expectErr: &ViewDependencyUnresolvedError{View: "user_earnings_ranking", MissingReferencedEntities: []string{"earnings"}},
},
}
for _, ts := range tt {
Expand Down
Binary file modified web/vtadmin/public/favicon.ico
Binary file not shown.
3 changes: 2 additions & 1 deletion web/vtadmin/src/components/NavRail.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ a.navLink {
font-size: 1.6rem;
font-weight: 500;
outline: none;
padding: 13px 24px;
padding: 10px 24px;
text-decoration: none;
transition: $navRailHoverTransition;

Expand Down Expand Up @@ -109,6 +109,7 @@ a.navLink:hover .badge {
fill: var(--colorScaffoldingForeground);
height: 2rem;
transition: $navRailHoverTransition;
margin-right: 10px;
}

a.navLinkActive .icon,
Expand Down
3 changes: 0 additions & 3 deletions web/vtadmin/src/components/NavRail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@ export const NavRail = () => {
<li>
<NavRailLink hotkey="W" text="Workflows" to="/workflows" count={workflows.length} />
</li>
</ul>

<ul className={style.navList}>
<li>
<NavRailLink hotkey="M" text="Migrations" to="/migrations" />
</li>
Expand Down
61 changes: 30 additions & 31 deletions web/vtadmin/src/components/VitessLogo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,54 +2,53 @@ import React from 'react';

const VitessLogo: React.FC<{ className?: string }> = ({ className }) => {
return (
<svg xmlns="http://www.w3.org/2000/svg" role="img" viewBox="-5.48 13.27 440.96 403.96" className={className}>
<path fill="none" d="M76.774 158.098l-.011.012.011-.012z" />
<svg
width="207"
height="250"
viewBox="0 0 207 250"
fill="none"
xmlns="http://www.w3.org/2000/svg"
className={className}
>
<path
d="M242.742 258.203l.04-.206 13.593-79.583-13.633 79.789zm98.18-79.977l-44.115 79.726-83.395 151.07.003.006 83.411-151.095 44.116-79.716 48.195-87.421-48.215 87.43zM342.43 21.85l-14.161 25.877 14.167-25.877h-.006zM76.774 158.098l54.081-58.039-54.081 58.039zm11.512 21.02l59.724-47.442-59.724 47.442zm0 0l-4.007-7.304 3.997 7.304 42.494 78.004 6.9 12.722-6.906-12.739-42.478-77.987z"
className="fill-[#284e64]"
d="M189 194.177L200.111 196.792C203.459 197.581 206.666 195.041 206.666 191.601V57.0542C206.666 53.6199 203.468 51.0809 200.123 51.8599L189 54.4506V194.177Z"
fill="#FF8E50"
/>
<path
d="M103.185 151.448l27.67-51.389 17.155 31.617 33.263 61.357-33.244-61.366-17.169-31.634L88.096 21.85h-.009l42.768 78.209-27.67 51.389zm124.483 126.996l.196.361 8.008 14.721-8.204-15.082zm56.527-150.437l-27.835 50.39-30.963 57.017 30.978-57 27.82-50.407z"
className="fill-[#284e64]"
d="M174.45 210.577L157 205.279V186.642L181.333 192.371V205.474C181.333 209.054 177.876 211.617 174.45 210.577Z"
fill="#FF8E50"
/>
<path d="M173.214 335.413l40.189 73.625 22.118-113.708-62.307 40.083z" className="fill-[#f16827]" />
<path
d="M235.872 293.526l-8.008-14.721-27.453-50.469-27.197 107.077 62.307-40.083.351-1.804z"
className="fill-[#f48029]"
d="M181.333 56.2364L157 61.9038V43.3292L174.461 38.0697C177.885 37.0387 181.333 39.6014 181.333 43.1765V56.2364Z"
fill="#FF8E50"
/>
<path d="M157 186.642L181.333 192.371V56.2363L157 61.9038V186.642Z" fill="#E7481B" />
<path
d="M130.764 257.105l6.906 12.739 35.544 65.569 27.197-107.077-69.647 28.769z"
className="fill-[#f89a2e]"
d="M141.973 227.98L120 218.968V194.045L149.33 202.95V223.046C149.33 226.839 145.483 229.419 141.973 227.98Z"
fill="#FF8E50"
/>
<path
d="M130.764 257.105l69.647-28.769-19.138-35.303-33.263-61.357-17.246 125.429z"
className="fill-[#f16827]"
d="M149.33 45.6394L120 54.4738V29.619L141.984 20.6584C145.492 19.2287 149.33 21.8092 149.33 25.5973V45.6394Z"
fill="#FF8E50"
/>
<path d="M149 45.7389L120 54.4739V70.5216L149 63.7672V45.7389Z" fill="#E7481B" />
<path d="M149 184.759L120 177.931V194.045L149 202.85V184.759Z" fill="#E7481B" />
<path d="M149 63.7671L120 70.5215V177.931L149 184.759V63.7671Z" fill="#C71E07" />
<path
fill="#f89921"
d="M242.742 258.203l13.633-79.789-30.978 57-10.562 19.436 12.833 23.594 8.204 15.082 6.87-35.323z"
d="M104.02 1.55971L2.68726 59.4645C1.02553 60.414 0 62.1812 0 64.0951V185.756C0 187.668 1.02344 189.433 2.68249 190.384L104.016 248.427C107.571 250.463 112 247.896 112 243.799V215.687L20.9736 178.355C18.9716 177.534 17.6641 175.584 17.6641 173.42V74.9163C17.6641 72.7481 18.9766 70.7958 20.9843 69.9774L112 32.8799V6.19033C112 2.09528 107.576 -0.472012 104.02 1.55971Z"
fill="#FF8E50"
/>
<path d="M88.286 179.118l42.478 77.987 17.246-125.429-59.724 47.442z" className="fill-[#f89a2e]" />
<path d="M296.807 257.952l44.115-79.726-98.14 79.771 54.025-.045z" className="fill-[#f48029]" />
<path
fill="#f4ae5c"
d="M130.855 100.059l-27.67 51.389-14.899 27.67 59.724-47.442-17.155-31.617zm111.927 157.938l56.555-157.423-15.142 27.433-27.82 50.407-13.593 79.583z"
d="M112 32.8798L20.9843 69.9774C18.9766 70.7957 17.6641 72.7481 17.6641 74.9162V173.42C17.6641 175.584 18.9716 177.534 20.9736 178.355L112 215.687V191.616L46.7839 171.815C44.5365 171.133 43 169.061 43 166.712V81.6302C43 79.2772 44.5421 77.2022 46.7952 76.5235L112 56.8835V32.8798Z"
fill="#E7481B"
/>
<path
d="M88.286 179.118l14.899-27.67 27.67-51.389-54.081 58.039-.011.012 7.516 13.704 4.007 7.304z"
className="fill-[#cd4e27]"
d="M112 56.8834L46.7952 76.5235C44.5421 77.2021 43 79.2771 43 81.6302V166.712C43 169.061 44.5365 171.133 46.7839 171.815L112 191.616V176.047L79.111 168.304C76.7023 167.737 75 165.587 75 163.112V85.2365C75 82.757 76.7087 80.6046 79.1235 80.0422L112 72.3848V56.8834Z"
fill="#C71E07"
/>
<path
fill="#f16938"
d="M340.922 178.226l-41.585-77.652-56.555 157.423 98.14-79.771zM76.774 158.098l54.081-58.039L88.087 21.85l-.006-.01-11.318 136.27.011-.012z"
/>
<path
d="M340.922 178.226l1.519-156.376v-.01l-.005.01-14.167 25.877-28.932 52.847 41.585 77.652zM88.081 21.84H3l73.763 136.27L88.081 21.84z"
className="fill-[#f89a2e]"
/>
<path
d="M342.441 21.84v.01l-1.519 156.376 48.215-87.43 38.028-68.956h-84.724zm-99.659 236.157l-.04.206-6.87 35.323-.351 1.804-22.118 113.708.009-.016 83.395-151.07-54.025.045z"
className="fill-[#cd4e27]"
d="M112 72.3849L79.1235 80.0422C76.7087 80.6047 75 82.7571 75 85.2365V163.113C75 165.587 76.7023 167.737 79.111 168.304L112 176.047V72.3849Z"
fill="#9E0C03"
/>
</svg>
);
Expand Down

0 comments on commit 18bab44

Please sign in to comment.