diff --git a/public/Import-DbaParquet.ps1 b/public/Import-DbaParquet.ps1 index a49d5b8c4a1..5be72f99e24 100644 --- a/public/Import-DbaParquet.ps1 +++ b/public/Import-DbaParquet.ps1 @@ -320,7 +320,12 @@ function Import-DbaParquet { param([string]$Path) $stream = [System.IO.File]::OpenRead($Path) try { - $reader = [Parquet.ParquetReader]::CreateAsync($stream).GetAwaiter().GetResult() + # leaveStreamOpen has to be passed as false. It defaults to true, which means disposing the + # reader leaves the file stream open and the file stays locked until the garbage collector + # finalizes it - so the imported file could not be deleted or overwritten for an arbitrary + # time after the import finished. All four arguments are passed because the overload that + # takes a stream can only be selected by its full signature. + $reader = [Parquet.ParquetReader]::CreateAsync($stream, $null, $false, [System.Threading.CancellationToken]::None).GetAwaiter().GetResult() return $reader } catch { $stream.Dispose()