@@ -5,13 +5,13 @@ import (
55 "testing"
66
77 "github.com/src-d/gitbase"
8- "github.com/stretchr/testify/require"
9- errors "gopkg.in/src-d/go-errors.v1"
108 "github.com/src-d/go-mysql-server/sql"
119 "github.com/src-d/go-mysql-server/sql/analyzer"
1210 "github.com/src-d/go-mysql-server/sql/expression"
1311 "github.com/src-d/go-mysql-server/sql/parse"
1412 "github.com/src-d/go-mysql-server/sql/plan"
13+ "github.com/stretchr/testify/require"
14+ errors "gopkg.in/src-d/go-errors.v1"
1515)
1616
1717func TestAnalyzeSquashJoinsExchange (t * testing.T ) {
@@ -407,6 +407,7 @@ func TestBuildSquashedTable(t *testing.T) {
407407 refsCommitFilesSchema := append (gitbase .RefsSchema , gitbase .CommitFilesSchema ... )
408408 commitsCommitFilesSchema := append (gitbase .CommitsSchema , gitbase .CommitFilesSchema ... )
409409 commitFilesFilesSchema := append (gitbase .CommitFilesSchema , gitbase .FilesSchema ... )
410+ commitFilesBlobsSchema := append (gitbase .CommitFilesSchema , gitbase .BlobsSchema ... )
410411
411412 repoFilter := eq (
412413 col (0 , gitbase .RepositoriesTableName , "repository_id" ),
@@ -713,6 +714,16 @@ func TestBuildSquashedTable(t *testing.T) {
713714 col (0 , gitbase .FilesTableName , "file_path" ),
714715 )
715716
717+ commitFilesBlobsRedundantFilter := eq (
718+ col (0 , gitbase .CommitFilesTableName , "blob_hash" ),
719+ col (0 , gitbase .BlobsTableName , "blob_hash" ),
720+ )
721+
722+ commitFilesBlobsFilter := eq (
723+ col (0 , gitbase .CommitFilesTableName , "commit_hash" ),
724+ col (0 , gitbase .BlobsTableName , "blob_size" ),
725+ )
726+
716727 idx1 , idx2 := & dummyLookup {1 }, & dummyLookup {2 }
717728
718729 testCases := []struct {
@@ -2085,6 +2096,41 @@ func TestBuildSquashedTable(t *testing.T) {
20852096 gitbase .FilesTableName ,
20862097 )),
20872098 },
2099+ {
2100+ "commit_files with blobs" ,
2101+ []sql.Table {commitFiles , blobs },
2102+ []sql.Expression {
2103+ blobFilter ,
2104+ commitFilesFilter ,
2105+ commitFilesBlobsFilter ,
2106+ commitFilesBlobsRedundantFilter ,
2107+ },
2108+ nil ,
2109+ nil ,
2110+ nil ,
2111+ plan .NewResolvedTable (gitbase .NewSquashedTable (
2112+ gitbase .NewCommitFileBlobsIter (
2113+ gitbase .NewAllCommitFilesIter (
2114+ fixIdx (t , commitFilesFilter , gitbase .CommitFilesSchema ),
2115+ ),
2116+ and (
2117+ fixIdx (t , blobFilter , commitFilesBlobsSchema ),
2118+ fixIdx (t , commitFilesBlobsFilter , commitFilesBlobsSchema ),
2119+ ),
2120+ false ,
2121+ ),
2122+ nil ,
2123+ []sql.Expression {
2124+ blobFilter ,
2125+ commitFilesFilter ,
2126+ commitFilesBlobsFilter ,
2127+ commitFilesBlobsRedundantFilter ,
2128+ },
2129+ nil ,
2130+ gitbase .CommitFilesTableName ,
2131+ gitbase .BlobsTableName ,
2132+ )),
2133+ },
20882134 {
20892135 "commit_files with indexes" ,
20902136 []sql.Table {commitFiles , files },
0 commit comments